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

AttributeError: module 'dill._dill' has no attribute 'PY3' #113

Open
demongolem-biz2 opened this issue Oct 31, 2023 · 5 comments
Open

AttributeError: module 'dill._dill' has no attribute 'PY3' #113

demongolem-biz2 opened this issue Oct 31, 2023 · 5 comments

Comments

@demongolem-biz2
Copy link

I am trying to learn how to fine-tune. As such, I am running to run preparation for end-to-end question generations as given:

python prepare_data.py
--task e2e_qg
--valid_for_qg_only \
--model_type t5
--dataset_path data/squad_multitask/
--qg_format highlight_qg_format
--max_source_length 512
--max_target_length 32
--train_file_name train_data_e2e_qg_t5.pt
--valid_file_name valid_data_e2e_qg_t5.pt \

I get the following stack trace:

File "/home/gregory.werner/question_generation/prepare_data.py", line 165, in main
train_dataset = train_dataset.filter(TASK_TO_FILTER_FN[data_args.task])
File "/home/gregory.werner/cpython-3.10.13/python/lib/python3.10/site-packages/nlp/arrow_dataset.py", line 1053, in filter
return self.map(
File "/home/gregory.werner/cpython-3.10.13/python/lib/python3.10/site-packages/nlp/arrow_dataset.py", line 902, in map
cache_file_name = self._get_cache_file_path(function, cache_kwargs)
File "/home/gregory.werner/cpython-3.10.13/python/lib/python3.10/site-packages/nlp/arrow_dataset.py", line 756, in _get_cache_file_path
function_bytes = dumps(function)
File "/home/gregory.werner/cpython-3.10.13/python/lib/python3.10/site-packages/nlp/utils/py_utils.py", line 278, in dumps
dump(obj, file)
File "/home/gregory.werner/cpython-3.10.13/python/lib/python3.10/site-packages/nlp/utils/py_utils.py", line 271, in dump
Pickler(file).dump(obj)
File "/home/gregory.werner/cpython-3.10.13/python/lib/python3.10/site-packages/dill/_dill.py", line 418, in dump
StockPickler.dump(self, obj)
File "/home/gregory.werner/cpython-3.10.13/python/lib/python3.10/pickle.py", line 487, in dump
self.save(obj)
File "/home/gregory.werner/cpython-3.10.13/python/lib/python3.10/site-packages/dill/_dill.py", line 412, in save
StockPickler.save(self, obj, save_persistent_id)
File "/home/gregory.werner/cpython-3.10.13/python/lib/python3.10/pickle.py", line 560, in save
f(self, obj) # Call unbound method with explicit self
File "/home/gregory.werner/cpython-3.10.13/python/lib/python3.10/site-packages/dill/_dill.py", line 1965, in save_function
_save_with_postproc(pickler, (_create_function, (
File "/home/gregory.werner/cpython-3.10.13/python/lib/python3.10/site-packages/dill/_dill.py", line 1093, in _save_with_postproc
pickler.save_reduce(*reduction, obj=obj)
File "/home/gregory.werner/cpython-3.10.13/python/lib/python3.10/pickle.py", line 692, in save_reduce
save(args)
File "/home/gregory.werner/cpython-3.10.13/python/lib/python3.10/site-packages/dill/_dill.py", line 412, in save
StockPickler.save(self, obj, save_persistent_id)
File "/home/gregory.werner/cpython-3.10.13/python/lib/python3.10/pickle.py", line 560, in save
f(self, obj) # Call unbound method with explicit self
File "/home/gregory.werner/cpython-3.10.13/python/lib/python3.10/pickle.py", line 902, in save_tuple
save(element)
File "/home/gregory.werner/cpython-3.10.13/python/lib/python3.10/site-packages/dill/_dill.py", line 412, in save
StockPickler.save(self, obj, save_persistent_id)
File "/home/gregory.werner/cpython-3.10.13/python/lib/python3.10/pickle.py", line 560, in save
f(self, obj) # Call unbound method with explicit self
File "/home/gregory.werner/cpython-3.10.13/python/lib/python3.10/site-packages/nlp/utils/py_utils.py", line 304, in save_code
if dill._dill.PY3:
AttributeError: module 'dill._dill' has no attribute 'PY3'

Is this a versioning thing maybe where I have to old or new of a version of something?

@demongolem-biz2
Copy link
Author

demongolem-biz2 commented Oct 31, 2023

I don't really get nlp vs datasets. I guess I thought datasets was the same, but newer.

But anyhow, I took code from datasets file utils/py_utils.py in save_code method to hardcode the correct args in the nlp version and it worked. So there seems to be something about the tutorial which needs updating? I had initially tried replacing nlp with datasets in the prepare_data.py code but that did not work for some other reason.

@THANH-SSV
Copy link

AttributeError: module 'dill._dill' has no attribute 'PY3'
Have you solved this problem? Can you tell me? I really don't know what to deal with

@ZZZZkp
Copy link

ZZZZkp commented Apr 5, 2024

I don't really get nlp vs datasets. I guess I thought datasets was the same, but newer.

But anyhow, I took code from datasets file utils/py_utils.py in save_code method to hardcode the correct args in the nlp version and it worked. So there seems to be something about the tutorial which needs updating? I had initially tried replacing nlp with datasets in the prepare_data.py code but that did not work for some other reason.

Don't forget the usage of nlp in squad_multitask.py.

@nitheeshk03
Copy link

AttributeError: module 'dill._dill' has no attribute 'PY3' Have you solved this problem? Can you tell me? I really don't know what to deal with

I faced the same issue and installing dill version 0.3.5 worked for me
pip install dill==0.3.5

@imkhoibui
Copy link

AttributeError: module 'dill._dill' has no attribute 'PY3' Have you solved this problem? Can you tell me? I really don't know what to deal with

You should either use a lower version of nlp (specifically 0.2.0) or just use datasets package and adapt everything else altogether.

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

No branches or pull requests

5 participants