GPU Enabled Open CV for Xavier NX - Python3

I have been trying to get the cuda enabled opencv package on my Xavier NX 8 GB. I tried running this script https://forums.developer.nvidia.com/uploads/short-url/9S2NQYQjeFeBIW02RHxnqaLy9Fd.sh it seems to have built correctly but the “Python (for build):” line says “usr/bin/python2.7”. Python 3 seems to be running a different version of opencv and does not have access to cuda functionality. Only python 2 works. Any suggestions?
Running python 2.7 :
import cv2
print(cv2.version)
‘4.5.1’

Running Python 3.6:
import cv2
print(cv2.version)
‘4.5.5’

Edit: I got it to import for Python 3. 6 by adding -D PYTHON_DEFAULT_EXECUTABLE=/usr/bin/python3.6. But its full of linking problem, gstreamer (won’t read from webcam now) ect. Also on another front C++ won’t compile anything. Really a nightmare. Why doesn’t nvidia provide the image with cuda version of opencv?

Hi,

Have you tried to install the OpenCV with pip3 tool?
Since the prebuilt package doesn’t enable GStreamer, it’s quite possible that you link to the prebuilt rather than the library building from the source.

Thanks.

Thanks for the reply. How can I ensure pip links to the library building from source? Also any advice on c++ opencv issues? The #include of helper files says they cannot be found. I tried moving the files in /opencv4/opencv2/ directly into the /include parent directory. This fixed it saying it cannot be found but then threw tons of other errors when defining any opencv Mat variable. There something I missing? A step that should be taken after running the .sh script I posted above?

I’ll also note that my python3 and c++ code compiling are all good with software on fresh flash of jetpack. Obviously not using any cuda functions in my scripts.

Following the instructions here and changing CUDA_ARCH_BIN to 7.2 fixed everything on a clean install of jetpack. Installing OpenCV 4.5.2 - Viking Drone

1 Like

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