OpenCV, CUDA, Python with Jetson Nano

I’m not sure what you mean by checking cmake outputs, or how to confirm they point to the python and numpy files.

you may try set up opencv manually,
executing steps of the script one by one with manual revision

Ill try that. Do you know how can I unmake the changes introduced to my system via the supplied install script so that I can start all over again manually?

generally you execute

make install

upon completion of manual installation
and that links newest installed libraries to default system paths.
what can be considered is as well:

sudo apt purge opencv*

Though, in my opinion, a way to deselect thee default opencv 3.4 during the sdk manager installation process might be found in the future that will waive that need.
You may also delete default download folder if it is represented from previous installation.

I just uninstalled the default opencv via

sudo apt-get remove python3-opencv

just to verify that I can reinstall it later if needed also via apt-get:

sudo apt-get install python3-opencv

That gives me some peace of mind.
Now I need to undo whatever actions the install script made, but:

sudo apt purge opencv*

did nothing at all


make install

is not meant for uninstalling, so I’m not sure how I am supposed to remove all the libraries and stuff that were put in the system path during the install step.

On the other hand, the opencv-4.0.0 directory that is used during installation is not there anymore (I don’t see in which step is deleted), so I’m also not sure where are the make rules are defined. The only directory that is left after installation is the opencv_contrib-4.0.0, but it has no makefiles or anything that looks compilable.

you may try

apt autoremove
drakorg@drakorg-desktop:~$ sudo apt autoremove
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 164 not upgraded.

Nothing. Im still stuck with some 4.0.0 libraries, with no python bindings btw. Id like to find a way to remove all this without having to manually delete all links and files, if possible.

Well, just found that the file was only 4M in size, when it should’ve been like 90M. Maybe thats why the directory didnt even exist. Ok. Ill try to start over again.

you may like to download and install a newer release

I’ll do that, thanks. Well, I just ran out of space on the SD so I think its time to start from the very beginning again. Thank you for your advice.
Best regards.

In case you’d like to install opencv-3.4.6 on Jetson Nano (since opencv-4.x does not work for caffe), you could refer to my blog post. I’ve put all necessary steps into 1 single script.

“Installing OpenCV 3.4.6 on Jetson Nano”:


I’m aware of those patches, but I’m not sure if they apply to SSD caffe (or other flavors of caffe) which I’m using mostly.

Does your script’s builds pass tests with “make test”? You have to set the cmake flags to build the tests as well?

When I ran tests with CUDA built in, basic sanity checks were failing on the cuda parts. On the OpenCV provided by Nvidia, CUDA is not built in at all.

See for yourself with print(cv2.getBuildInformation())

OpenCV would appear to need work before CUDA works 100% on Nano.

One last quick thing I spotted: installing pip is unnecessary since it’s already installed and may break things that way. You can install pip on Ubuntu with sudo apt install python-pip or ... python3-pip for python3. Headers are in -dev packages. I don’t think pip is needed to build. Deps I used:

sudo apt-get install -y \
        build-essential \
        cmake \
        git \
        libavcodec-dev \
        libavresample-dev \
        libavformat-dev \
        libdc1394-22-dev \
        libgstreamer1.0-dev \
        libgtk2.0-dev \
        libjpeg-dev \
        libpng-dev \
        libswscale-dev \
        libtbb-dev \
        libtbb2 \
        libtiff-dev \
        libv4l-dev \
        pkg-config \
        python-dev \
        python-numpy \
        python3-dev \

If the python bindings don’t build, please make sure there is enough memory (mount swap or cross compile). Please see this issue on my OpenCV build script, which seems to happen with them all:

@mdegans, thanks a lot for pointing out the testing of opencv. I just ran the test.

$ cd ${HOME}/src
$ git clone
$ cd ${HOME}/src/opencv-3.4.6/build
$ make clean
$ cmake ...... -D BUILD_TESTS=ON ......  # details omitted
$ OPENCV_TEST_DATA_PATH=${HOME}/src/opencv_extra/test_data make test

There were indeed a few failed tests. I think most of them could be related to the ‘-D ENABLE_FAST_MATH=ON -D CUDA_FAST_MATH=ON’ options, which I explicitly set in order to trade float-point computation accuracy for speed.

More specifically, here’s the list of failed tests.

  • opencv_test_core: 3 failures in test_mat.cpp, which I think could be related to FAST_MATH.
  • opencv_test_cudaarithm: lots of failures caused by opengl code, which is for graphics rendering and doesn't bother me.
  • opencv_test_ml: 1 failure related 'waveform_gaussian' which I'm sure I don't use.
  • opencv_test_cudaimgproc: 2 failures related to 'mean shift' which I won't use.
  • opencv_test_photo: 6 failures related to photo cloning/merging.
  • opencv_test_calid3d: 2 failures due to bad arguments (bugs in opencv's test code?)
  • opencv_test_objdetect: 1 failure in Objdetect_CascadeDetector which I think is related to FAST_MATH
  • opencv_test_cudalegacy: 2 failures which don't matter.

@mdegans, this is related to your question about installing pip3. I use ‘’ ( to install the latest version of pip3, because some of the machine learning modules (such as pandas) might require a newer version of pip to install. In fact, based on my own experience, running ‘’ has always worked for me on Linux platforms. It could even fix a broken pip on the system.

There’s one more thing I think worth mentioning about the way I install opencv on the Jetson platforms. I use Qt backend (-D WITH_QT=ON -D WITH_OPENGL=ON) instead of the default GTK+ backend. By doing this, my opencv libraries are not linked to libprotobuf. This helps me to avoid protobuf version related problems later on when I build/run caffe and tensorflow.

I explained that a little bit more in my blog post ( Check it out if interested.

I’m going to assume those flags set float to fp16 or something? TBH I am not certain what that flag does for sure. I haven’t googled around for it yet. If you know, i’d love to know as well.

You can try removing it and going again. I would think, however, that the tests would account for the flags.

I didn’t wait for it to finish, but please do post your results.

I understand, but from my perspective it modifies the system pip, which is unexpected behavior.

Sorry for confusing you. I forgot to remove the “To be updated” in the test result list. I did let all tests finish. The list was complete.

As to CUDA_FAST_MATH, please refer to this paragraph in NVIDIA’s CUDA programming documentation:

Aha. That’s considerably less broken than version 4 from my recollection of running tests.

Ctrl+f must be failing on that page. I searched for CUDA_FAST_MATH and found nothing.


I did a search on github.

So there’s this in CMakeLists:


but what tells me where to look next is:

OCV_OPTION(CUDA_FAST_MATH "Enable --use_fast_math for CUDA compiler " OFF)

    set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} --use_fast_math)


And i found it. Thanks!