Cuda installation for opencv exist just for Python2

Hey community,

I installed opencv with the following link : Install OpenCV 4.5 on Jetson Nano - Q-engineering .
I started with the header Download OpenCV and tried to install opencv with cuda. After the installation i get only for python2 the information about cuda and for python3 i cant see any cuda builds.
I followed exactly the instruductions.

should I enable python examples or should I change the cmake comands.

I see all Information with cv.getBuildInformation() and start it with python2 and python3.

Thanks for reply.

It is common that opencv fails to install for both python2 and python3.
You may get to your build directory, and change config with:

cmake \
-D BUILD_opencv_python2=OFF \
-D PYTHON3_EXECUTABLE=$(which python3) \
-D BUILD_opencv_python3=ON \
-D PYTHON3_INCLUDE_DIR=$(python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \ 
-D PYTHON3_PACKAGES_PATH=$(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \
.

then rebuild, install and verify.

Thank you @Honey_Patouceul ,

I added your configuration and get an error.

cmake 	-D CMAKE_BUILD_TYPE=RELEASE \
	-D CMAKE_INSTALL_PREFIX=/usr \
	-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules \
	-D EIGEN_INCLUDE_PATH=/usr/include/eigen3 \
	-D WITH_OPENCL=OFF \
	-D WITH_CUDA=ON \
	-D CUDA_ARCH_BIN=5.3 \
	-D CUDA_ARCH_PTX="" \
	-D WITH_CUDNN=ON \
	-D WITH_CUBLAS=ON \
	-D ENABLE_FAST_MATH=ON \
	-D CUDA_FAST_MATH=ON \
	-D OPENCV_DNN_CUDA=ON \
	-D ENABLE_NEON=ON \
	-D WITH_QT=OFF \
	-D WITH_OPENMP=ON \
	-D BUILD_TIFF=ON \
	-D WITH_FFMPEG=ON \
	-D WITH_GSTREAMER=ON \
	-D WITH_TBB=ON \
	-D BUILD_TBB=ON \
	-D BUILD_TESTS=OFF \
	-D WITH_EIGEN=ON \
	-D WITH_V4L=ON \
	-D WITH_LIBV4L=ON \
	-D OPENCV_ENABLE_NONFREE=ON \
	-D INSTALL_C_EXAMPLES=OFF \
	-D INSTALL_PYTHON_EXAMPLES=OFF \
	-D BUILD_opencv_python2=OFF \
	-D PYTHON3_EXECUTABLE=/usr/bin/python3 \
	-D BUILD_opencv_python3=ON \
	-D PYTHON3_INCLUDE_DIR=/usr/include/python3.6m \ 
	-D PYTHON3_PACKAGES_PATH=/usr/lib/python3/dist-packages \
	-D OPENCV_GENERATE_PKGCONFIG=ON \
	-D BUILD_EXAMPLES=OFF ..

after -D PYTHON3_INCLUDE_DIR cmake says : The source directory "/home/sinanjetson/opencv/build/ " does not exist.

without adding your configuration it doesnt show any errors.

I tried also with this comand but it is the same error

-D PYTHON3_INCLUDE_DIR=$(python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \ 

what did I wrong?

Thanks for your answer

What gives:

python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())"

I get the following path

Try creating a directory aside from opencv sources:

mkdir build-release
ls
# this should show :       build-release  opencv  opencv_contrib 

cd build-release
cmake \
-D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D WITH_CUDA=ON \
-D WITH_CUDNN=ON \
-D CUDA_ARCH_BIN="5.3" \
-D CUDA_ARCH_PTX="" \
-D WITH_OPENGL=ON \
-D WITH_QT=ON \
-D OPENCV_GENERATE_PKGCONFIG=ON \
-D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules \
-D WITH_FFMPEG=ON \
-D WITH_GSTREAMER=ON \
-D WITH_LIBV4L=ON \
-D BUILD_EXAMPLES=OFF \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D PYTHON_EXECUTABLE=$(which python2) \
-D BUILD_opencv_python2=OFF \
-D PYTHON3_EXECUTABLE=$(which python3) \
-D BUILD_opencv_python3=ON \
-D PYTHON3_INCLUDE_DIR=$(python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \
-D PYTHON3_PACKAGES_PATH=$(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \
-D BUILD_TESTS=OFF \
-D BUILD_PERF_TESTS=OFF \
../opencv

make
sudo make install

I tried your configuration and it is the same result so I try the configiguration from q-engineering again and reconized after cmake configuration that Libraries set NO and install path doesnt exist.

I followed the path shown in the webside form q-engineering I couldnt find libpython3.6m.so . So what I found is libpython3.6m.so.1 and libpython3.6m.so.1.0.

But with cv.2getBuildInformation it shows libpython3.6m.so path.

How can i fix this?
Thank you for reply

Sorry, I fail to understand your case.
I tested this script before posting without any issue (on a different JP version and platform, but this shouldn’t matter that much).
Maybe you have a non standard setup and environnement that makes it wrong and you may try saving your work into an external storage and reflash.
Or maybe you have some missing dependencies, you may install these and build with the install_opencv4.5.0_Jetson.sh script at:

Sorry i didnt know that external storage would affected it. I have a Jetson Nano with emmc storage and I copied the OS to the SD card. After that installed packages with sdk manager and tried to install opencv with cuda

At the beginning is opencv 4.1.1 installed and has no cuda or other configurations.

would it help to install pip ?

I solved the problem with an other way.
I flashed an usb drive with the image data from GitHub - Qengineering/Jetson-Nano-image: Jetson Nano image with deep learning frameworks.
It has all configurations installed.

So because of the emmc the image dont work but i copy the /usr file from it and pasted it to my bootable sd card which I mentioned before.
Saved the old usr file in my host computer.

Hopefully it does work but I have not so much knowledge that I can say that is healthy for my jetson nano.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.