Colab: libtorch_cuda_cu.so: cannot open shared object file: No such file or directory warn(f"Failed to load image Python extension: {e}")
Asked Answered
C

1

7

I'm trying to use the python package aitextgen in google Colab so I can fine-tune GPT.

First, when I installed the last version of this package I had this error when importing it.

Unable to import name '_TPU_AVAILABLE' from 'pytorch_lightning.utilities'

Though with the help of the solutions given in this question I could pass this error by downgrading my packages like this:

!pip3 install -q aitextgen==0.5.2
!pip3 install -q torchtext==0.10.0
!pip3 install -q torchmetrics==0.6.0
!pip3 install -q pytorch-lightning==1.4.0rc0

But now I'm facing this error when importing the aitextgen package and colab will crash!

/usr/local/lib/python3.8/dist-packages/torchvision/io/image.py:13: UserWarning: Failed to load image Python extension: libtorch_cuda_cu.so: cannot open shared object file: No such file or directory
  warn(f"Failed to load image Python extension: {e}")

Keep in mind that the error is in importing the package and there is not a bug in my code. To be more clear I have this error when I just import aitextgen like this:

import aitextgen

How can I deal with this error?

Cuba answered 16/12, 2022 at 9:31 Comment(0)
C
1

It seems that it is due to your CUDA version (it can be the cuDNN version too) not matching the supported version by tf, torch, or jax.

As of Aug 2023, If your CUDA or cuDNN versions are +12, try downgrading them. You can find your CUDA version with nvcc --version and your cuDNN version via apt list --installed | grep cudnn.

And you can downgrade your cuDNN with this (there could be other methods too):

sudo apt-get install libcudnn8=8.8.1.3-1+cuda11.8
sudo apt-get install libcudnn8-dev=8.8.1.3-1+cuda11.8
Cuba answered 3/8, 2023 at 18:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.