Skip to content. | Skip to navigation

Personal tools


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:

  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


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

Add comment

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

Question: What is 23 plus 19?
Your answer: