Users usually install the needed dependencies like this
!pip install numba-cuda[cu12]
in the first cell of a notebook, and then use it in the next cell
from numba import cuda, ...
However, this does not work with the .pth redirector that we add to overwrite the upstream CUDA target:
https://github.com/NVIDIA/numba-cuda/tree/main/site-packages
because the .pth files must be executed at the startup time of the Python interpreter, and this execution logic implies that Python is already started by the Jupyter kernel.
Based on the offline discussion with @shwina we don't think there is a fix. Once the upstream Numba drops the CUDA target, we can drop this redirector. Before that happens, we can apply any of the workarounds below:
- Restart the kernel after
!pip install
- Install the packages in terminal instead of cell, prior to starting a notebook
import _numba_cuda_redirector before import numba or from numba import cuda
Users usually install the needed dependencies like this
in the first cell of a notebook, and then use it in the next cell
However, this does not work with the .pth redirector that we add to overwrite the upstream CUDA target:
https://github.com/NVIDIA/numba-cuda/tree/main/site-packages
because the .pth files must be executed at the startup time of the Python interpreter, and this execution logic implies that Python is already started by the Jupyter kernel.
Based on the offline discussion with @shwina we don't think there is a fix. Once the upstream Numba drops the CUDA target, we can drop this redirector. Before that happens, we can apply any of the workarounds below:
!pip installimport _numba_cuda_redirectorbeforeimport numbaorfrom numba import cuda