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 Dec 22, 2019 10:10 AM
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???

Now one environment variable needs to be set:

CUDA_HOME=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2

Doesn't matter how you set it, e.g. system environment var, or in your IDE,...

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 42 minus 19?
Your answer: