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

ModuleNotFoundError: No module named 'transformers.pytorch_transformers' #59

Closed
NguyenVanThanhHust opened this issue Feb 4, 2021 · 12 comments

Comments

@NguyenVanThanhHust
Copy link

Hi, thank for your work.

I'm trying to finetune for image captioning task. When i run

python oscar/run_captioning.py \
    --model_name_or_path pretrained_models/base-vg-labels/ep_67_588997 \
    --do_train \
    --do_lower_case \
    --evaluate_during_training \
    --add_od_labels \
    --learning_rate 0.00003 \
    --per_gpu_train_batch_size 64 \
    --num_train_epochs 30 \
    --save_steps 5000 \
    --output_dir output/

I encounter this error

2021-02-04 06:41:10.151589: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /usr/local/cuda/lib:/usr/local/cuda/lib64:/usr/local/nvidia/lib:/usr/local/nvidia/lib64
2021-02-04 06:41:10.151621: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
Traceback (most recent call last):
  File "test.py", line 5, in <module>
    from transformers.pytorch_transformers.modeling_utils import PreTrainedModel
ModuleNotFoundError: No module named 'transformers.pytorch_transformers'

I clone this repo with cmd

git clone https://github.com/microsoft/Oscar.git
git submodule init
git submodule update

How could i fix this issue?

@brightbsit
Copy link

Check if u have a transformers folder and files and put right directory path on the code.

@NguyenVanThanhHust
Copy link
Author

Hi @brightbsit,

I have transformers folder, i git cloned that folder in above comment. I checked file in that folder too. There are folder pytorch_transformers.

And what do you mean about " put right directory path on the code"?

I clone from this git, both main and submodule. Am I supposed to put folder "transformers" somewhere else?

@brightbsit
Copy link

brightbsit commented Feb 4, 2021

I also have the same error and change the path on the code.

change the line 5 in file "test.py". also "python setup.py build develop" might help.

@NguyenVanThanhHust
Copy link
Author

How shoud i change that line ?
This is line 5

from transformers.pytorch_transformers.modeling_utils import PreTrainedModel

What should i change it too?

@brightbsit
Copy link

Umm it depends on the folder states. I think i just add . In the beginning

@NguyenVanThanhHust
Copy link
Author

Is this what you mean?

from .transformers.pytorch_transformers.modeling_utils import PreTrainedModel

If so then the error is:

Traceback (most recent call last):
  File "test.py", line 5, in <module>
    from .transformers.pytorch_transformers.modeling_utils import PreTrainedModel
ImportError: attempted relative import with no known parent package

And what do you mean about folder states? I leaves the folder structure as in git.

And python setup.py build develop doesn't work either.

@brightbsit
Copy link

I don't have any problem with the test. But I can't find test.py file on my oscar folder. Where did u get test.py file?

the code will be gone when you fix the path.

@NguyenVanThanhHust
Copy link
Author

NguyenVanThanhHust commented Feb 6, 2021

test.py is a file i created.
Error happen when i run

python oscar/run_captioning.py \
    --model_name_or_path pretrained_models/base-vg-labels/ep_67_588997 \
    --do_train \
    --do_lower_case \
    --evaluate_during_training \
    --add_od_labels \
    --learning_rate 0.00003 \
    --per_gpu_train_batch_size 64 \
    --num_train_epochs 30 \
    --save_steps 5000 \
    --output_dir output/

I know error happended because of it can't import file.

To reduce time, i copy import code from oscar/run_captioning.py

To replicate error, you can run original cmd.

It creates exactly same error.

@brightbsit
Copy link

what is the error code when you type python setup.py build develop?

@NguyenVanThanhHust
Copy link
Author

I don't see any error when i run sudo python3.7 setup.py build develop.

Thank you for your patience.

I just build a docker and run it in docker.

I suspect this error has something to do with call library.

@alice-cool
Copy link

pip uninstall transformers

@Skyy93
Copy link

Skyy93 commented Mar 23, 2022

thank you @alice-cool

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

4 participants