Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
---------------------------------------------------------------------------
PicklingError Traceback (most recent call last)
File /opt/conda/lib/python3.8/site-packages/huggingface_hub/fastai_utils.py:296, in _save_pretrained_fastai(learner, save_directory, config)
295 try:
--> 296 learner.export(
297 fname="model.pkl",
298 pickle_protocol=DEFAULT_PROTOCOL,
299 )
300 except PicklingError:
File /opt/conda/lib/python3.8/site-packages/fastai/learner.py:378, in export(self, fname, pickle_module, pickle_protocol)
377 warnings.simplefilter("ignore")
--> 378 torch.save(self, self.path/fname, pickle_module=pickle_module, pickle_protocol=pickle_protocol)
379 self.create_opt()
File /opt/conda/lib/python3.8/site-packages/torch/serialization.py:380, in save(obj, f, pickle_module, pickle_protocol, _use_new_zipfile_serialization)
379 with _open_zipfile_writer(opened_file) as opened_zipfile:
--> 380 _save(obj, opened_zipfile, pickle_module, pickle_protocol)
381 return
File /opt/conda/lib/python3.8/site-packages/torch/serialization.py:589, in _save(obj, zip_file, pickle_module, pickle_protocol)
588 pickler.persistent_id = persistent_id
--> 589 pickler.dump(obj)
590 data_value = data_buf.getvalue()
PicklingError: Can't pickle <function <lambda> at 0x7f1f1a5d7670>: attribute lookup <lambda> on __main__ failed
During handling of the above exception, another exception occurred:
PicklingError Traceback (most recent call last)
Input In [21], in <module>
----> 1 push_to_hub_fastai(learn, "kurianbenoy/music_genre_classification_baseline", commit_message="Add new Learner")
File /opt/conda/lib/python3.8/site-packages/huggingface_hub/fastai_utils.py:436, in push_to_hub_fastai(learner, repo_id, commit_message, private, token, config, **kwargs)
427 repo = Repository(
428 repo_id,
429 clone_from=repo_url,
(...)
432 git_email=git_email,
433 )
434 repo.git_pull(rebase=True)
--> 436 _save_pretrained_fastai(learner, repo_id, config=config)
438 return repo.push_to_hub(commit_message=commit_message)
File /opt/conda/lib/python3.8/site-packages/huggingface_hub/fastai_utils.py:301, in _save_pretrained_fastai(learner, save_directory, config)
296 learner.export(
297 fname="model.pkl",
298 pickle_protocol=DEFAULT_PROTOCOL,
299 )
300 except PicklingError:
--> 301 raise PicklingError(
302 "You are using a lambda function, i.e., an anonymous function. `pickle`"
303 " cannot pickle function objects and requires that all functions have"
304 " names. One possible solution is to name the function."
305 )
PicklingError: You are using a lambda function, i.e., an anonymous function. `pickle` cannot pickle function objects and requires that all functions have names. One possible solution is to name the functio
@kurianbenoy
Copy link
Author

kurianbenoy commented May 1, 2022

image

@kurianbenoy
Copy link
Author

kurianbenoy commented May 16, 2022

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment