ValueError: libcublas.so.*[0-9] not found in the system path

15.6k Views Asked by At

I'm trying to import and use ultralytics library in my Django rest framework project, I use poetry as my dependency manager, I installed ultralytics using poetry add ultralytics and on trying to import the library in my code I recieve this error

ValueError: libcublas.so.*[0-9] not found in the system path [my project and virtual environment paths]

how can I solve that?

7

There are 7 best solutions below

2
Sven On

You have to install cuda on your system.

E.g. on ubuntu:

sudo apt-get install nvidia-cuda-toolkit nvidia-cuda-toolkit-gcc
0
TojaQl On

If you come here and have this problem with some other library while using poetry, try to install it directly in .venv. For me that was:

   pip3 install "transformers[torch]"
1
Noumenon On

Update: this issue was fixed in PyTorch 2.1.1.

Since May 9 2023 there is an open issue with PyTorch 2.0.1 and 2.1.0 causing poetry lock to delete libcublas from poetry.lock. Their wheel contains the dependency, but their PyPi upload did not get it.

A workaround would be to skip these versions in pyproject.toml (typically under [tool.poetry.dependencies]):

torch = ">=2.0.0, !=2.0.1, !=2.1.0"

Make sure to run the following to correctly update your poetry env after making the change

poetry lock --no-update
poetry install
0
s4mdf0o1 On

according to this response :

https://github.com/pytorch/pytorch/issues/100974#issuecomment-1541856571

you can also install the nvidia-* dependencies specifically, in your poetry venv / pyproject.toml

1
stackerlacker On

add this to pyproject.toml

torch = ">=2.0.0, !=2.0.1, !=2.1.0"

poetry install

THIS WORKS

ok im not exactly sure how it works. I checked my history I'm still confused but when the correct version is selected you should see poetry install would install a bunch of nvidia libraries. after that when I run my script it works perfectly

0
KARTHIK MVP On

add this to pyproject.toml

torch = ">=2.0.0, !=2.0.1, !=2.1.0"

poetry lock --no-update

poetry install

0
Daniel Ajisafe On

What caused the issue in my case was deleting .local folder where local library files are usually stored. I uninstalled torch and did a conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia which removed the error and was the beginning of the solution.