12

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?

desertnaut
  • 57,590
  • 26
  • 140
  • 166

3 Answers3

19

Since May 9 2023 there is an open issue with PyTorch 2.0.1 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 this version in pyproject.toml:

torch = ">=2.0.0, !=2.0.1"

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

poetry lock --no-update
poetry install
azizbro
  • 3,069
  • 4
  • 22
  • 36
Noumenon
  • 5,099
  • 4
  • 53
  • 73
  • I changed pyproject.toml to torch = ">2.0.0, !=2.0.1" and ran command poetry update torch. It worked. Then i changed pyproject.toml back to torch="^2.0.1" and ran update again. Surprisingly import worked with torch 2.0.1 too. – Neeraj Sharma Jul 12 '23 at 11:24
  • @NeerajSharma I assume >2.0.0 is a typo since there is no version that matches ">2.0.0, !=2.0.1". I think `poetry update torch` doesn't change `poetry.lock` so it shouldn't cause the error to begin with. I tried running `poetry lock` with ">=2.0.0, !=2.0.1" followed by ^2.0.1, but it didn't work for me. – Noumenon Jul 12 '23 at 16:53
  • my pyproject.toml looks like this and working fine [tool.poetry.dependencies] python = ">=3.8,<3.12" ipykernel = "^6.24.0" torch = ">=2.0.0, !=2.0.1" sklearn = "^0.0.post5" scikit-learn = "^1.3.0" tensorflow = "^2.13.0" pandas = "^2.0.3" pillow = "^10.0.0" seqeval = "^1.2.2" transformers = "4.13.*" albumentations = "^1.3.1" – Neeraj Sharma Aug 10 '23 at 08:20
  • @NeerajSharma Since you're using the solution in the answer now and not `^2.0.1`, can I just delete all these comments as no longer needed? – Noumenon Aug 10 '23 at 14:00
1

You have to install cuda on your system.

E.g. on ubuntu:

sudo apt-get install nvidia-cuda-toolkit nvidia-cuda-toolkit-gcc
Sven
  • 1,014
  • 1
  • 11
  • 27
1

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]"
TojaQl
  • 23
  • 5