Skip to content
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

Use Safetensors instead of Pickle #30

Open
JD-The-65th opened this issue May 31, 2023 · 1 comment
Open

Use Safetensors instead of Pickle #30

JD-The-65th opened this issue May 31, 2023 · 1 comment
Labels
question Further information is requested

Comments

@JD-The-65th
Copy link

JD-The-65th commented May 31, 2023

Hey, I was wondering why we're using pickle instead of safetensors? Pickle is insecure, with a modified pickle file being able to run arbitrary code, and is causing an error (for me, at least) when running this notebook locally, with the error in question being:

UnpicklingError                           Traceback (most recent call last)
Cell In[12], line 11
      9 get_ipython().system('wget -c https://openaipublic.blob.core.windows.net/minecraft-rl/models/{multiplier}.model -O model')
     10 get_ipython().system('wget -c {weights_file} -O weights')
---> 11 agent_parameters = pickle.load(open("model", "rb"))
     12 policy_kwargs = agent_parameters["model"]["args"]["net"]["args"]
     13 pi_head_kwargs = agent_parameters["model"]["args"]["pi_head_opts"]

UnpicklingError: A load persistent id instruction was encountered,
but no persistent_load function was specified.

If possible, I think the model should be converted to safetensors, which I would say is almost becoming a new standard for ml files.

@Miffyli Miffyli added the question Further information is requested label Jun 1, 2023
@Miffyli
Copy link
Collaborator

Miffyli commented Jun 1, 2023

Hmm not sure what is causing that error, although yes, this might be just as simple as the pickle library being too different.

That file does not actually store the weights but the model settings (e.g., arguments for creating the model of right shape). True, it could be saved in json, but I think there were some objects or weirder classes in the mix that would have made it more difficult.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants