-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Python 3.8: "an integer is required (got type bytes)" when loading models saved under older Python versions #171
Comments
After further investigation, this also applies to I think the common point is that these can all be callables, right? They were also created using |
Does the same happen with saving/loading models with stable-baselines3 alone without the files in zoo? The code for saving and loading has changed since those zoo models were trained so it might have broken a thing or two. |
It happens for models trained using a version of SB3 pulled from Git a week ago, albeit with Python 3.7 |
Just to clarify: You train a model with older version of SB3 (week ago), save it, update to current SB3 (master) and loading fails? |
the issue comes with the pretrained models (using python 3.6) that are available in the zoo. |
seems like an issue coming from cloudpickle + python 3.8 |
Hmm either rl-zoo should provide parameters of networks which can be loaded (which then skips training parameters...) or update loading code to catch errors like this and then ask for user to provide that object as part of the custom objects (that override the loaded values), and then rl-zoo provides these values. |
Rolling back to commit 00595b0 was not sufficient to get the rl-zoo examples working again. I think it's indeed a problem with pickling in 3.8. |
Given that pickle/cloudpickle are not meant for long term usage (the explicitly state that it should not be used for such purpose), I think this kind of errors are expected. Moving completely away from pickling does not make much sense since models can have custom agents, but I think we need to add something to make this kind of situations easier to handle (e.g. like providing the invalid values manually). |
I found that it comes from this PR way, way upstream: python/cpython#12701, referenced here. It breaks the constructor of code objects, which include functions defined from functions and saved using Seeing this I agree having a nice fallback would be more elegant until things are sorted out upstream. |
✋ Hi, CPython maintainer here. Unfortunately, there is nothing to be done in our side, as the signature of code objects is not considered stable between versions. The constructor is purpously not even documented and we have this advice here:
(https://docs.python.org/3/library/types.html#standard-interpreter-types) You can also use this new convenience method that we added to make the transition easier for people using code objects: https://docs.python.org/3/library/types.html#types.CodeType.replace |
Thanks for your input, I'll see about contributing a fallback for our specific problem and a more general fix for the cloudpickle dependency, though their loading code seems actually be |
closing this in favor of #172 (and as it is not an issue coming from SB3) |
Describe the bug
There is an issue loading trained agent files in Python 3.8.
Code example
I checked this on the
rl-baselines3-zoo
repository.System Info
Describe the characteristic of your environment:
Additional context
I printed out info and saw that it occurs when loading the data key
learning_rate
on the SAC example above. For policies trained using recent versions of SB3 it happens forlr_schedule
.The text was updated successfully, but these errors were encountered: