error: library nvvm not found

I am using Ubuntu 16.04 and I am trying to execute this code:

import numpy as np
from timeit import default_timer as timer
from numba import vectorize
# This should be a substantially high value. On my test machine, this took
# 33 seconds to run via the CPU and just over 3 seconds on the GPU.
NUM_ELEMENTS = 100000000
# This is the CPU version.
def vector_add_cpu(a, b):
  c = np.zeros(NUM_ELEMENTS, dtype=np.float32)
  for i in range(NUM_ELEMENTS):
    c[i] = a[i] + b[i]
  return c
# This is the GPU version. Note the @vectorize decorator. This tells
# numba to turn this into a GPU vectorized function.
@vectorize(["float32(float32, float32)"], target='cuda')
def vector_add_gpu(a, b):
  return a + b;
def main():
  a_source = np.ones(NUM_ELEMENTS, dtype=np.float32)
  b_source = np.ones(NUM_ELEMENTS, dtype=np.float32)
  # Time the CPU function
  start = timer()
  vector_add_cpu(a_source, b_source)
  vector_add_cpu_time = timer() - start
  # Time the GPU function
  start = timer()
  vector_add_gpu(a_source, b_source)
  vector_add_gpu_time = timer() - start
  # Report times
  print("CPU function took %f seconds." % vector_add_cpu_time)
  print("GPU function took %f seconds." % vector_add_gpu_time)
  return 0
if __name__ == "__main__":

I got the error:

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

I have followed but it is not working.
Could someone help me?

echo $PATH


nvcc --version
nvcc: NVIDIA ® Cuda compiler driver
Copyright © 2005-2018 NVIDIA Corporation
Built on Tue_Jun_12_23:07:04_CDT_2018
Cuda compilation tools, release 9.2, V9.2.148

sudo find / -name nvvm

find: ‘/run/user/1000/gvfs’: Permission denied

why not do

conda install cudatoolkit

as the error suggested?

It will install an extra copy of the CUDA toolkit (probably CUDA 9.0, in the anaconda directory somewhere) but that won’t hurt anything, and is the easiest way to get your numba/cuda install working.

Alternatively you could try the instructions that were given at the end of the CUDA toolkit install, to create a file in


directory, with the path to the CUDA libraries (/usr/local/cuda-9.2/lib64)

and then do

sudo ldconfig

but I’m not really sure that will solve all the problems of getting your numba install to use your installed CUDA toolkit. In my experience its a lot easier just to do conda install cudatoolkit, as suggested.

I did conda install cudatoolkit

But the I only can run the code using terminal:


I got the error in the IDE (pycharm and Wing IDE).

The image:

It is almost certainly an IDE configuration issue. These links may help: