Python OpenCV with CUDA support in CONDA env

Hi there,
Sorry for the noob question…

I’ve recently acquired an Xavier NX and am planning to develop a high speed computer vision application on it. As a part of setting the development environment, my objective is to be able to use numba and the “pre-packaged” opencv with cuda support that comes ready with Jetpack.
I’ve managed to install numba as part of a conda env as per this link,

However, I’m struggling to import the Jetpack’s “pre-packaged” opencv as the errors in the attached screenshot

Any help/pointers are greatly appreciated


Please remember to add --system-site-packages flag to import the host module within a virtual environment.
You can find an example in the below comment:

More, the pre-installed OpenCV doesn’t enable GPU support.
If you want a GPU version of OpenCV, please build it from the source.

Here is a script to building OpenCV v4.5.5 from source for your reference:


@AastaLLL thank you for the reply, but I’m trying to also use numba, which installs on a conda environment and unfortunately I can’t create a conda environment with the --system-site-packages, and I couldn’t find an equivalent flag/option for conda.

As for the pre-installed OpenCV, it does seem to already have cuda support as the attached screenshot


Sorry that CUDA support does enable in the current OpenCV package.
So you don’t need to build it from the source anymore!

For numba, it seems they do support the Jetson platform with conda.
Have you tried the installation command in their document?


Yes, I’ve managed to install numba in the conda environment on the Xavier NX, however I’m struggling with getting OpenCV to work inside the conda environment (that numba is installed)…

Things I’ve tried:

  1. creating symlink from the preinstalled OpenCV → this gives error
  2. install OpenCV from source inside the conda env using cmake → for some reason the python config is not correct as per the screenshot

I’m here to answer my own question, incase if anyone encounters the same problem that I did…

Turns out it’s pretty simple, if I had put some thought into it, here goes my steps…

  1. check what is the preinstalled python version that corresponds to the preinstalled opencv, in my case it was python 3.6
  2. follow the instructions to build the conda env and install numba from it’s official site here with one minor tweak… after successfully installing conda with the config setup, but before the “conda install -c numba numba” step, create a new conda env that uses the same python version as found in 1), in my case I created a new conda env as “conda create --name cv python=3.6”
  3. once the new conda env is created THEN proceed with “conda install -c numba numba” to install numba
  4. once numba is installed, then create a symlink from where the preinstalled opencv is located to the conda’s python site-packages directory, now you can use the preinstalled cv2 with numba…