27

I am trying to run the code below but an error is reported:

NvvmSupportError: libNVVM cannot be found. Do conda install cudatoolkit: library nvvm not found

My development environment is: Ubuntu 17.04, Spyder/Python3.5 and I have installed via conda (numba and cudatoolkit). Nvidia GPUs (GTX 1070 and GTX 1060).

import numpy as np
from timeit import default_timer as timer
from numba import vectorize

@vectorize(["float32(float32, float32)"], target='cuda')     
def VecADD(a,b):
    return a+b        

n = 32000000
a = np.ones (n, dtype=np.float32) 
b = np.ones (n, dtype=np.float32)     
c = np.zeros(n, dtype=np.float32) 

start = timer()
C = VecADD(a,b)
print (timer() - start)

Does anyone know how to solve this problem?

Helton Maia
  • 271
  • 1
  • 4
  • 5
  • 1
    sounds like either the GPU driver or CUDA toolkit is not installed correctly. After installing the CUDA toolkit, did you set the PATH and LD_LIBRARY_PATH environment variables correctly? Did you validate the CUDA toolkit install? Are there any libnvvm libraries at /usr/local/cuda/nvvm/lib64 ? – Robert Crovella Jan 22 '18 at 16:14
  • I am suspecting (if I recall correctly), don't you need to specify which GPU to use first? – stucash Jan 22 '18 at 16:16
  • 1
    @stucash: no you don't. The code as posted works straight out of the box for me – talonmies Jan 22 '18 at 17:09
  • @talonmies right I guess I was wrong then :) – stucash Jan 22 '18 at 17:13
  • 1
    I did several tests, I believe it's a PATH problem, but I still can not solve it. Anyway, I tested it on jupyter-notebook and it's working perfect, I'll use it for now. Thanks! – Helton Maia Jan 24 '18 at 00:31
  • I have this problem as well, and so far I can't seem to solve it. I've tried many of the below to .bashrc, but to no avail. Is there a conclusive solution? – thecpaptain Sep 22 '20 at 18:26

9 Answers9

21

What worked for me under exactly the same scenario was to include the following in the .bashrc (I'm currently using cuda-9.0). Don't be thrown off by the NUMBAPRO in the variable name - it works for numba (at least for me):

export NUMBAPRO_NVVM=/usr/local/cuda-9.0/nvvm/lib64/libnvvm.so
export NUMBAPRO_LIBDEVICE=/usr/local/cuda-9.0/nvvm/libdevice/

Update: It worked for me too. As I'm using Cuda 10.1, I have included the following lines instead of yours:

export NUMBAPRO_NVVM=/usr/local/cuda-10.1/nvvm/lib64/libnvvm.so
export NUMBAPRO_LIBDEVICE=/usr/local/cuda-10.1/nvvm/libdevice/
Community
  • 1
  • 1
Py_Dream
  • 363
  • 2
  • 10
  • 1
    For me it worked to add those environment variables to the environment variables list under Debug Configuration within PyCharm. – JEM_Mosig Aug 02 '18 at 15:32
  • 1
    @JEM_Mosig FYI, or anyone else who wants to access it from terminal, you can add those lines to your ~/.bashrc file - its a hidden file in your home directory – mur Jan 02 '19 at 08:49
  • Thank you. Your solution worked on our HPC system (though the paths are different) – upendra Apr 04 '19 at 04:56
  • 1
    Installing from `miniconda3` I had to use these paths: `export NUMBAPRO_NVVM=/opt/miniconda3/lib/; export NUMBAPRO_LIBDEVICE=/opt/miniconda3/lib/` Also see: http://numba.pydata.org/numba-doc/latest/cuda/overview.html#cudatoolkit-lookup – elig Jun 07 '19 at 02:17
  • This answer is wrong. It is out of date. The correct answer is to set `CUDA_HOME` to `/usr/local/cuda-10.1` in the above example. – rjurney Apr 29 '23 at 06:40
2

One Solution is:

import os

os.environ['NUMBAPRO_NVVM']      = r'C:\Program Files\NVIDIA GPU Computing 
Toolkit\CUDA\v8.0\nvvm\bin\nvvm64_31_0.dll'

os.environ['NUMBAPRO_LIBDEVICE'] = r'C:\Program Files\NVIDIA GPU Computing 
Toolkit\CUDA\v8.0\nvvm\libdevice'

Or if you are using PyCharm GO TO RUN > Edit Configuration

export NUMBAPRO_NVVM=/usr/local/cuda-{cuda version}/nvvm/lib64/libnvvm.so
export NUMBAPRO_LIBDEVICE=/usr/local/cuda-{cuda version}/nvvm/libdevice/

enter image description here

Mina Gabriel
  • 23,150
  • 26
  • 96
  • 124
2

On Ubuntu 18.04 if you install all libraries and packages from the official repository, you need to add two information on your .bashrc to allow numba to find your libraries and device:

...
export NUMBAPRO_LIBDEVICE=/usr/lib/cuda/nvvm/libdevice
export NUMBAPRO_NVVM=/usr/lib/x86_64-linux-gnu/
...

NUMBAPRO_LIBDEVICE information was extracted from the package:

$ dpkg -L nvidia-cuda-toolkit

and NUMBAPRO_NVVM from:

$ dpkg -L libnvvm3

That's it.

1

Just in case that someone else stumbles on a similar issue the provided environment variables suggested on the other answers are not anymore supported. Are deprecated and replaced with CUDA_HOME http://numba.pydata.org/numba-doc/latest/cuda/overview.html#setting-cuda-installation-path.

ttsesm
  • 917
  • 5
  • 14
  • 28
0

I solved this problem using anaconda-navigator. You can download here: https://www.anaconda.com/distribution/

  1. Open anaconda navigator in Terminal: anaconda-navigator
  2. In anaconda navigator select Environments
  3. search for cudatoolkit
  4. select cudatoolkit
  5. click in apply

This is my cudatoolkit installed. anaconda navigator

This is the button to click when you select a not installed package button to click apply

0

In my experience, all of these CUDA (and similar driver) problems go away if you use a container from https://ngc.nvidia.com/catalog/landing.

You must ensure that you start docker with nvidia-docker instead of docker and it will enable GPU related drivers very effectively.

jmsinusa
  • 1,584
  • 1
  • 13
  • 21
0

In a Debian Stretch system:

ln -s /usr/lib/x86_64-linux-gnu/ /usr/lib/nvidia-cuda-toolkit/bin/nvvm/lib64

ln -s /usr/lib/nvidia-cuda-toolkit/libdevice/ /usr/lib/nvidia-cuda-toolkit/bin/nvvm/libdevice

export CUDA_HOME=/usr/lib/nvidia-cuda-toolkit/bin/


Fixed the pb..

0

Debian »Buster« with CUDA 10.2 (and pip3 instead conda)

numba -s
…
CUDA libraries:
Finding cublas
    ERROR: can't locate lib
Finding cusparse
    ERROR: can't locate lib
Finding cufft
    ERROR: can't locate lib
Finding curand
    ERROR: can't locate lib
Finding nvvm
    ERROR: can't locate lib
    finding libdevice for compute_20... ERROR: can't open libdevice for compute_20
    finding libdevice for compute_30... ERROR: can't open libdevice for compute_30
    finding libdevice for compute_35... ERROR: can't open libdevice for compute_35
    finding libdevice for compute_50... ERROR: can't open libdevice for compute_50
…

then a manual

sudo ln -sv /usr/lib/x86_64-linux-gnu/libcublas.so.10 /usr/local/cuda/lib64/ 
export NUMBAPRO_CUDALIB=/usr/local/cuda/lib64/
export NUMBAPRO_LIBDEVICE=/usr/local/cuda/nvvm/libdevice/ 
export NUMBAPRO_NVVM=/usr/local/cuda/nvvm/lib64/libnvvm.so

and we get

numba -s
…
CUDA libraries:
Finding cublas
    named  libcublas.so.10
    trying to open library...   ok
Finding cusparse
    named  libcusparse.so.10.3.1.89
    trying to open library...   ok
Finding cufft
    named  libcufft.so.10.1.2.89
    trying to open library...   ok
Finding curand
    named  libcurand.so.10.1.2.89
    trying to open library...   ok
Finding nvvm
    named  libnvvm.so
    trying to open library...   ok
    finding libdevice for compute_20... ok
    finding libdevice for compute_30... ok
    finding libdevice for compute_35... ok
    finding libdevice for compute_50... ok
…
Jaleks
  • 561
  • 5
  • 19
0

On Windows, if CUDA is installed properly, usually nvvm is here.

"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\nvvm\libdevice"

Don't forget to keep it in path for the programs to find it.

H S Rathore
  • 1,954
  • 2
  • 15
  • 20