Skip to content. | Skip to navigation

Personal tools

Navigation

You are here: Home / Members / jhb / Numba and Cuda on Windows (using pip)

Numba and Cuda on Windows (using pip)

by Jörg Baach last modified Oct 22, 2018 05:10 PM
How to install numba to run with a nvidia card on windows.

The basic outline is described here: http://numba.pydata.org/numba-doc/latest/user/installing.html#installing-using-pip-on-x86-x86-64-platforms

  1. Install the cuda sdk
  2. pip install numba
  3. set the environment variables
  4. nothing works???

It took me some googling to find out that I need to set exactly two environment variables (not three!):

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

With this I can run example code like this one:

from numba import cuda
import numpy as np
import numba

numba.cuda.profile_stop()

@cuda.jit
def max_example(result, values):
"""Find the maximum value in values and store in result[0]"""
tid = cuda.threadIdx.x
bid = cuda.blockIdx.x
bdim = cuda.blockDim.x
i = (bid * bdim) + tid
cuda.atomic.max(result, 0, values[i])


arr = np.random.rand(16384)
result = np.zeros(1, dtype=np.float64)

max_example[256,64](result, arr)
print(result[0]) # Found using cuda.atomic.max
print(max(arr)) # Print max(arr) for comparision (should be equal!)

(Taken from http://numba.pydata.org/numba-doc/0.25.0/cuda/intrinsics.html)

Add comment

You can add a comment by filling out the form below. Plain text formatting.

Question: What is 6 times 7?
Your answer: