advimman / lama

🦙 LaMa Image Inpainting, Resolution-robust Large Mask Inpainting with Fourier Convolutions, WACV 2022
https://advimman.github.io/lama-project/
Apache License 2.0
7.99k stars 849 forks source link

google colab: ModuleNotFoundError: No module named 'torchtext.legacy' #114

Closed hanp0 closed 2 years ago

hanp0 commented 2 years ago

The colab demo now has an module error when training and predicting, possibly due to to colab changes?

from torchtext.legacy.data import Batch ModuleNotFoundError: No module named 'torchtext.legacy'

devriesewouter89 commented 2 years ago

I'm experiencing the same behaviour, though as the git repo hasn't changed a lot, I believe it could be a pytorch/torchtext compatibility issue.

kiashann commented 2 years ago

Did you solve this problem? @hanp0 @devriesewouter89 @windj007

terwelja commented 2 years ago

I solved this issue for myself @kiashann. You need to install an earlier version of torchtext and torchvision, I personally chose torchtext/torchvision 0.9.0, and wrote !pip install torchtext==0.9.0 --quiet and !pip install torchvision==0.9.0 --quiet after the fix opencv line. I think Google Colab installed a version of pytorch that was incompatible with LaMa.

hanp0 commented 2 years ago

@terwelja when I try that I get

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
torchvision 0.12.0+cu113 requires torch==1.11.0, but you have torch 1.8.0 which is incompatible.
torchaudio 0.11.0+cu113 requires torch==1.11.0, but you have torch 1.8.0 which is incompatible.

when installing and then

RuntimeError: CUDA error: no kernel image is available for execution on the device

when trying to train?

kiashann commented 2 years ago

I solved this issue for myself @kiashann. You need to install an earlier version of torchtext and torchvision, I personally chose torchtext/torchvision 0.9.0, and wrote !pip install torchtext==0.9.0 --quiet and !pip install torchvision==0.9.0 --quiet after the fix opencv line. I think Google Colab installed a version of pytorch that was incompatible with LaMa.

Thanks for your response. How did you run train.py file? I used this command (!python bin/train.py -cn lama-fourier-celeba data.batch_size=10) but I got below error

Traceback (most recent call last): File "bin/train.py", line 21, in from saicinpainting.training.trainers import make_training_model ModuleNotFoundError: No module named 'saicinpainting'

devriesewouter89 commented 2 years ago

I can confirm that the combination !pip install torchtext==0.9.0 --quiet and !pip install torchvision==0.9.0 --quiet works for the colab notebook. @kiashann, I guess you need to set your PYTHONPATH correctly (e.g. !PYTHON_PATH=/content/lama if you downloaded the lama git in a notebook)

Op wo 4 mei 2022 om 12:35 schreef kiashann @.***>:

I solved this issue for myself @kiashann https://github.com/kiashann. You need to install an earlier version of torchtext and torchvision, I personally chose torchtext/torchvision 0.9.0, and wrote !pip install torchtext==0.9.0 --quiet and !pip install torchvision==0.9.0 --quiet after the fix opencv line. I think Google Colab installed a version of pytorch that was incompatible with LaMa.

Thanks for your response. How did you run train.py file? I used this command (!python bin/train.py -cn lama-fourier-celeba data.batch_size=10) but I got below error

Traceback (most recent call last): File "bin/train.py", line 21, in from saicinpainting.training.trainers import make_training_model ModuleNotFoundError: No module named 'saicinpainting'

— Reply to this email directly, view it on GitHub https://github.com/saic-mdal/lama/issues/114#issuecomment-1117161906, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFMQIRHHGOMKVOIJS7SIVNTVIJHI3ANCNFSM5URVO52Q . You are receiving this because you were mentioned.Message ID: @.***>

-- Wouter Devriese +32 495 15 73 09

hanp0 commented 2 years ago

@devriesewouter89 are you training in colab or only predicting?

devriesewouter89 commented 2 years ago

@hannah I'm only inferring images (predict and replace background)

Op wo 4 mei 2022 om 17:41 schreef Hannah @.***>:

@devriesewouter89 https://github.com/devriesewouter89 are you training in colab or only predicting?

— Reply to this email directly, view it on GitHub https://github.com/saic-mdal/lama/issues/114#issuecomment-1117505991, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFMQIRCU6GMY7BEB5EGBM5LVIKLAZANCNFSM5URVO52Q . You are receiving this because you were mentioned.Message ID: @.***>

-- Wouter Devriese +32 495 15 73 09

windj007 commented 2 years ago

Hi! It's great to see that you help each other! What questions remain unsolved?

windj007 commented 2 years ago

We neither use nor install torchtext - that library comes by default in colab and they might have changed the default version - so reinstall another version (e.g. 0.9.0) is an appropriate solution

windj007 commented 2 years ago

@kiashann to resolve No module named 'saicinpainting' issue, export PYTHONPATH=/content/lama environment variable

hanp0 commented 2 years ago

Hi! It's great to see that you help each other! What questions remain unsolved?

I'm still encountering the following error when trying to train using the solution above

RuntimeError: CUDA error: no kernel image is available for execution on the device

windj007 commented 2 years ago

@hanp0 You're encountering CUDA error: no kernel image is available for execution on the device because you've installed torchvision and torchaudio pre-built for cuda11.3 (see +cu113 in version) - but torch itself is built for another cuda. It seems that you've run pip install -U torchvision torchaudio - which just upgrades to the latest versions and does not check compatibility with the existing packages (that's how pip works).

windj007 commented 2 years ago

I've checked now - colab now has torch 1.11.0+cu113 by default, which is too recent for the LaMa codebase. I'll try to install 1.8 and the corresponding libraries now

windj007 commented 2 years ago

Fixed in 8ba8381