23
votes

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?

8
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
I am suspecting (if I recall correctly), don't you need to specify which GPU to use first? - stucash
@stucash: no you don't. The code as posted works straight out of the box for me - talonmies
@talonmies right I guess I was wrong then :) - stucash
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

8 Answers

19
votes

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/
3
votes

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

2
votes

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
votes

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
votes

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.

0
votes

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
votes

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
…
0
votes

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.