8

I am trying to @vectorize some python through CUDA. I'm running Python3 in atom with Cuda9.1, Anaconda3, and have a similar problem to this:

Cuda: library nvvm not found

but that solution is for linux and I'm on windows.

I gather from that solution above I need to add an Environment Variable. I tried to do just that by searching from the nvvm file which i found in:

C:\Users\ME\AppData\Local\Programs\Python\Python36\Lib\site-packages\numba\cuda\tests\cudadrv__pycache__

but adding that didn't help. I tried 'conda install cudatoolkit' as well as updating it.

Is my problem that the OS doesn't know where this library is? How to I point python to the library that it needs?

DaveP
  • 259
  • 4
  • 16

5 Answers5

6

I had this problem in late 2019 on CUDA 10.1 without Anaconda (everything installed through pip). The numba documentation said that it looks for CUDA first as configured by a conda package called cudatoolkit, but that wasn't applicable as I hadn't installed anything using conda. The second place it looks for CUDA is in the environment variable CUDA_HOME, and setting this to "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1" did the trick for me:

enter image description here

Thereafter, the errors go away and numba code runs.

rajb245
  • 251
  • 2
  • 6
  • 1
    This should get more votes because the problem has changed because of later versions. Setting environment variables with the NUMBAPRO prefix is deprecated it says when you try to use them. Only setting the CUDA_HOME variable worked for me in cuda version 10.2 – Mandera Dec 27 '19 at 00:00
  • I'm trying to do the same with CUDA version 10.2 but this is not working. Is there differences from 10.1 to 10.2 that causes this solution to fail? – ymmx Mar 10 '20 at 07:53
5

These are the environmental variables I set to get some pyCUDA example code running on Windows:

NUMBAPRO_NVVM = C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1\nvvm\bin\nvvm64_32_0.dll

NUMBAPRO_LIBDEVICE = C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1\nvvm\libdevice\

DavidH
  • 74
  • 1
2

You must remove the bar from the end.

NUMBAPRO_LIBDEVICE = C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1\nvvm\libdevice
8-Bit Borges
  • 9,643
  • 29
  • 101
  • 198
2

Python 3.7.0(x64 on AMD) on Windows 10(x64). Cuda 10

pip install --upgrade pip  
pip install numba
pip install numpy
pip install six

Also need to set system variable path as:

NUMBAPRO_NVVM=c:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\nvvm\bin\nvvm64_33_0.dll
NUMBAPRO_LIBDEVICE=c:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\nvvm\libdevice

Restart computer! (seems that is important for some reasons). This Works for me.

Nik
  • 21
  • 1
0

Tested with Windows 10 x64 + Python 3.10 + CUDA 11.8 + Tensorflow 2.10 + Anaconda (or Miniconda)

This will auto-detect the correct directory based on the current Anaconda environment which is py310tf in this case:

# [Bugfix]. Anaconda (or Miniconda) + Tensorflow: Prevent CUDA from warning that it cannot find nvvm when JIT compiling.
import subprocess
from pathlib import Path
anaconda_path_to_python = Path(subprocess.check_output("where python").decode("utf-8").split("\n")[0]).parent # Find Anaconda home directory.
os.environ["XLA_FLAGS"] = f"--xla_gpu_cuda_data_dir={anaconda_path_to_python}" # e.g. if Miniconda environment was py310tf this would be C:/Users/%USERNAME%/miniconda3/envs/py310tf
print(f"CUDA: Add path to find NVVM for JIT compiling: XLA_FLAGS={os.environ['XLA_FLAGS']}")

Output:

CUDA: Add path to find NVVM for JIT compiling: XLA_FLAGS=--xla_gpu_cuda_data_dir=C:\Users\Gravitas\miniconda3\envs\py310tf
Contango
  • 76,540
  • 58
  • 260
  • 305