Unable to install opencv with CUDA in Jetson Nano

While trying to run this example, got the following error.
Did I do something wrong, or just have to wait until the function is implemented?
Thanks

./build/opencv-4.0.0/release/bin/example_gpu_cascadeclassifier --cascade ./haarcascades/haarcascade_russian_plate_number.xml
Device 0: “NVIDIA Tegra X1” 3965Mb, sm_53, Driver/Runtime ver.10.0/10.0
terminate called after throwing an instance of ‘cv::Exception’
what(): OpenCV(4.0.0) /usr/share/OpenCV/build/opencv-4.0.0/modules/core/include/opencv2/core/private.cuda.hpp:113: error: (-213:The function/feature is not implemented) The called functionality is disabled for current build or platform in function ‘throw_no_cuda’

Aborted (core dumped)

Hi,

I just installed opencv 4.0.0 on my Nano using the script at https://github.com/AastaNV/JEP/blob/master/script/install_opencv4.0.0_Nano.sh

I installed it at using sudo ./install_opencv4.0.0_Nano.sh /usr/share/OpenCV . The installation went fine and I’m able to see the 4.0.0 files in subfolder within /usr/share/OpenCV .

However, when I use “pkg-config --modversion opencv”, I still see the 3.3 version. /usr/bin/opencv_version is still the old version.

I don’t need both versions. Should I have uninstalled the previous version? How do I do it cleanly? Alternatively, can I make any changes that will make the newer version the default one?

Is a new version of the Nano image with OpenCV4.0.0 installed coming in the near future?

Thanks,

Naren

Hi sivashakthi

I also run the script and it went fine. I can see opencv version as 4.0.0. But when I check the version through python3, I can still see 3.3.0 version.

Did you manage to remove the 3.3 version and use 4.0 by default? Thanks

I have exactly the same issue as sivashakthi (#22).
When using Python, how to specify the 4.0.0 version of CV2? Or how to cleanly uninstall the older version.

I would really appreciate if Nvidia developers could help.

Not sure it applies to your case, I’m running an older L4T release. However:

Python would load a cv2.so lib, you may check what opencv libs it depends on:

#python2.7
ldd /usr/lib/python2.7/dist-packages/cv2.so

#python3:
ldd /usr/lib/python3/dist-packages/cv2.so

If it shows wrong version, you may first check you have the lib built and installed for your opencv4 version and all its dependencies are available:

#python2.7
ldd <where_you_have_installed_opencv4>/lib/python2.7/dist-packages/cv2/python-2.7/cv2.so

#python3.5:
ldd <where_you_have_installed_opencv4>/lib/python3.5/dist-packages/cv2/python-3.5/cv2.cpython-35m-aarch64-linux-gnu.so

Note there are also some python scripts:

ls <where_you_have_installed_opencv4>/lib/python2.7/dist-packages/cv2/
ls <where_you_have_installed_opencv4>/lib/python3.5/dist-packages/cv2/

I haven’t used these and just went to save the old cv2.so lib and made a symbolic link to the new version and it worked out for me, but not sure how much this is correct…

sudo su

#python2.7
mv /usr/lib/python2.7/dist-packages/cv2.so /usr/lib/python2.7/dist-packages/cv2.so.old
ln -s  <where_you_have_installed_opencv4>/lib/python2.7/dist-packages/cv2/python-2.7/cv2.so /usr/lib/python2.7/dist-packages/cv2.so

#python3.5:
mv /usr/lib/python3/dist-packages/cv2.so /usr/lib/python3/dist-packages/cv2.so.old
ln -s <where_you_have_installed_opencv4>/lib/python3.5/dist-packages/cv2/python-3.5/cv2.cpython-35m-aarch64-linux-gnu.so /usr/lib/python3/dist-packages/cv2.so

exit

For opencv4 you would use instead

pkg-config --modversion opencv4

That script does build with CUDA on. Whether or not the GPU works is another thing. When I ran tests (tests are off in the build) a lot of things were failing, especially related to CUDA, while others passed. I ended up not running the full tests suite as in some tests a single process was using 11GB ram. I cancelled it rather than subject my sdcard to that.

No such file, I looked through /usr/lib/python3/dist-packages/ and nothing appears to be related to opencv/cv2.

Before I run the script, I clone JEP and create a opencv4 folder where I install it:

~/Downloads/JEP$ ls
CNN_model  README.md  opencv  script

Then I run

./install_opencv4.0.0_Nano.sh ~/Downloads/JEP/opencv

after the installation is done I have the following:

~/Downloads/JEP/opencv/opencv-4.0.0$ ls
3rdparty        CONTRIBUTING.md  README.md  cmake  doc      modules    release
CMakeLists.txt  LICENSE          apps       data   include  platforms  samples

So there is no lib folder the the directory in which I installed it to… Am I doing the installation wrong?

what are the steps you are executing? you may remove the whole thing and attempt executing lines manually with revision of each and with adjustment.
I would suggest to use virtual environment and specify python path to it as well as to numpy and make sure that cmake output points to them right.
Did you execute the command below?

sudo make install

normally if the file " cv2.so" is not presented, and file cv2.cpython* is presented you could just use symlink command to get the former.
if you can not find these files use the below:

sudo apt install mlocate
sudo updatedb
locate cv2
locate cpython

Pertaining : " how to specify the 4.0.0 version of CV2?"
you may use virtual environment for the purpose of separation of 4.0.0 installation,in my opinion. Though I would use 4.1.0 rather than 4.0.0.
And please utilize the native opencv support resources as chat and livechat[irc]
While nvidia supports opencv integration, it will bring more performance to use mmapi, deepstream, jetson inference etc. in most cases, as it seems to me. And answers to genertic issues with opencv can be found at their ecosystem including but not limited to #opencv irc chat e.g. at freenode.

The build is in release directory…but as mentioned by @Andrey1984 if you can get it installed through make install it should be better.
If this doesn’t improve, you may look to binaries built into ‘release’ directory:

find ~/Downloads/JEP/opencv/opencv-4.0.0/release -name 'cv2*.so'

and try to link these as said before.