-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Fix 32-bit env. model load issue #20900
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Summary: Fixed an issue where models can not be loaded in a 32-bit environment like Raspbian.
|
Thanks. Is there a way we can test this? |
Yes. Testing is possible with the Raspberry Pi. If you load the model like net.load_state_dict (torch.load (Config.model_save_path)) before the patch, the following backtrace will be output. ValueError Traceback (most recent call last) If you apply a patch, the above backtrace will not be output and loading will succeed. However, it takes 8 hours to build a PyTorch environment with Raspberry Pi3, so it is not reasonable if you do not have it on hand. So I have not tried it, but it might be better to test in a 32-bit Linux virtual environment. |
facebook-github-bot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ezyang is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
|
As far as I can tell this will overflow if |
|
Yes, this is a perfect fix for Unix systems, where sizeof(long)=4 in 32-bit system and sizeof(long)=8 in 64-bit system. But for Windows, sizeof(long)=4 for both 32-bit and 64-system systems. It is actually breaking the Windows build. |
|
In the first place, it seems that the logic to convert from va_arg to the stack for Python in PyObject_CallMethod () does not support LLP64 such as Windows. The do_mkvalue format string "l" is parsed with PyLong_FromLong (va_arg (* p_va, long)) and depends on the size of the long. Also, even if the format string is "L", it will be cast to long in PyLong_FromLongLong (), so you may not be able to handle files over 2GB on Windows. |
|
@yn4bit But PyLong is not only 32 bit, right? So what's the problem with PyLong_FromLongLong? |
|
I'm sorry. PyLong_FromLongLong () was referring to another file (Misc/coverity_model.c). Looking at Objects/longobject.c, it seems that it is stored in the Python stack in 64bit. Then, this part seems to be able to be corrected by passing long long as shown below. const auto seek_return = PyObject_CallMethod(file, "seek", "Li", (long long)fd_current_pos, 0); |
|
Would you please make a PR on this? |
|
OK. Wait a minute. |
|
@plang85 thank you for catching this before release. |
Summary:
Fixed an issue where models can not be loaded in a 32-bit environment like Raspbian.