-
-
Notifications
You must be signed in to change notification settings - Fork 55.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compiling Opencv 4.2.0 + CUDA on jetson nano board #16439
Comments
The build script you linked does not enable the CUDA backend for the DNN module. Please try building with this script. I have added the |
@YashasSamaga please advise. |
You have to purge the existing OpenCV installation and build using the script I provided. Your build time is 4 hours because you are building all the modules (even the ones you may not need). You might be able to reduce the build time by disabling the modules that you won't need. |
Thank you much. https://gist.github.com/YashasSamaga/e2b19a6807a13046e399f4bc3cca3a49 with the current installation when I try to execute your code I am getting the below error. yolov3_opencv_dnn_cuda.cpp:9:10: fatal error: opencv2/core.hpp: No such file or directory can you please advise. |
The OpenCV 4 headers are placed inside
|
Thank you, |
Scanning dependencies of target tegra_hal real 4m39.009s |
When I try to build your code then I am getting the below error. ( on jetson nano) Scanning dependencies of target tegra_hal real 4m39.009s please advise |
I am confused. The only changes I made were adding Can you try the solution given here: https://devtalk.nvidia.com/default/topic/1051752/jetson-tx2/build-opencv-3-4-with-cuda-on-nvidia-jetson-tx2/post/5338614/#5338614 |
@SaddamBInSyed You should check configuration flags of your build. Build / usage questions should go to Users OpenCV Q/A forum: http://answers.opencv.org |
@YashasSamaga please advise g++ yolov3_opencv_dnn_cuda.cpp -O3 -I/usr/local/include/opencv4 -lopencv_core -lopencv_dnn -lopencv_imgproc |
after linking lib its working fine. g++ main.cpp -O3 -I/usr/local/include/opencv4 -lopencv_core -lopencv_dnn -lopencv_imgproc -lopencv_core -lopencv_videoio -lopencv_highgui |
I have successfully compiled 4.2.0 for Jetson Nano with cudnn support and I am getting the following run time error. An ideas ?
|
global /tmp/build_opencv/opencv/modules/dnn/src/dnn.cpp (1363) setUpNet DNN module was not built with CUDA backend; switching to CPU I have just followed the instructions given above, but this is the error I am getting and moreover the external camera is not able to detect the image in the webcam frame. Any suggestions would help me. |
@SaiSandeepKantareddy Please show the CMake output. Are you using buildOpenCv.sh? |
Hi,
The cv2 components are here: #17372 as printed by the source I sent you.
If you need a full listing, I can run it again tonight and send you.
My "suspicion" is that maybe my models which came from pyimagesearch are for 32 bits and maybe the Jetson cuda needs 16bits and hence the errors ?
In the link above there is also a download link for the code (that you have) and the caffee model.
Best,
Mickey
…________________________________
From: Yashas Samaga B L <notifications@github.com>
Sent: Tuesday, May 26, 2020 4:42:27 PM
To: opencv/opencv <opencv@noreply.github.com>
Cc: tadam98 <tadam_98@hotmail.com>; Mention <mention@noreply.github.com>
Subject: Re: [opencv/opencv] Compiling Opencv 4.2.0 + CUDA on jetson nano board (#16439)
@SaiSandeepKantareddy<https://github.com/SaiSandeepKantareddy> Please show the CMake output. Are you using buildOpenCv.sh?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#16439 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AFBMCT2OXFOB2DBCOGTJG3DRTPBMHANCNFSM4KLW76EA>.
|
@tadam98 The code you sent is working on my computer. Are you sure that your locally built OpenCV 4.2 is being used instead of the OpenCV 4.1.2? (try printing |
Hi,
Yes, it is working on a pc.
The problem is on the jetson nano.
The printout in the github link i gave you was PRINTED BY THE PROGRAM ITSELF showing what the program sees in the cv2 library it is actually using. (See the 3rd print in the source from me, not the dowloaded one from phimagesearch)
Thus i am 100% certain it is using 4.2.0, with CUDA 10.2 and with cuDNN 8.0. (due to cuda 10.2 i had to correct cmake/FindCUDNN.cmake. Correcrions that worked well)
Before compiling the OpenCV 4.2.0 i did make uninstall and then a deep search after any remaining files of 4.1.2 and removed all. Including the 4.1.2 downloaded zips and compilation folders.
Best,
Mickey
…________________________________
From: Yashas Samaga B L <notifications@github.com>
Sent: Tuesday, May 26, 2020 6:33:40 PM
To: opencv/opencv <opencv@noreply.github.com>
Cc: tadam98 <tadam_98@hotmail.com>; Mention <mention@noreply.github.com>
Subject: Re: [opencv/opencv] Compiling Opencv 4.2.0 + CUDA on jetson nano board (#16439)
@tadam98<https://github.com/tadam98> The code you sent is working on my computer. Are you sure that your locally built OpenCV 4.2 is being used instead of the OpenCV 4.1.2? (try printing cv2.__version__)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#16439 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AFBMCT7XPCSJJMPDLMQLSH3RTPONJANCNFSM4KLW76EA>.
|
is the assertion that was triggered. The only way this can be triggered is if the backend is set to |
I was expecting to see a message that said OpenCV DNN had switched to CPU due to the unavailability of the CUDA backend. I don't see it. Can you try |
During run time is what I sent you with the parameters to the models that come in the zip. It is identical to the instructions on their website.
…________________________________
From: Yashas Samaga B L <notifications@github.com>
Sent: Tuesday, May 26, 2020 7:13:48 PM
To: opencv/opencv <opencv@noreply.github.com>
Cc: tadam98 <tadam_98@hotmail.com>; Mention <mention@noreply.github.com>
Subject: Re: [opencv/opencv] Compiling Opencv 4.2.0 + CUDA on jetson nano board (#16439)
CV_Assert(preferableBackend != DNN_BACKEND_OPENCV ||
preferableTarget == DNN_TARGET_CPU ||
preferableTarget == DNN_TARGET_OPENCL ||
preferableTarget == DNN_TARGET_OPENCL_FP16);
is the assertion that was triggered.
The only way this can be triggered is if the backend is set to DNN_BACKEND_OPENCV. What are the arguments you are passing to the script?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#16439 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AFBMCT65JKOQEA72A4MAQCTRTPTDZANCNFSM4KLW76EA>.
|
A command line parameter allows selection between use gpu or not. I tries both. So the problem is not with the gpu.
I will be by my pc in ah hour and will send you.
…________________________________
From: Yashas Samaga B L <notifications@github.com>
Sent: Tuesday, May 26, 2020 7:19:02 PM
To: opencv/opencv <opencv@noreply.github.com>
Cc: tadam98 <tadam_98@hotmail.com>; Mention <mention@noreply.github.com>
Subject: Re: [opencv/opencv] Compiling Opencv 4.2.0 + CUDA on jetson nano board (#16439)
I was expecting to see a message that said OpenCV DNN had switched to CPU due to the unavailability of the CUDA backend. I don't see it. Can you try export OPENCV_LOG_LEVEL=INFO in the terminal where you run the python script?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#16439 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AFBMCT4MFAIZ7ZUJM2XPFSLRTPTXNANCNFSM4KLW76EA>.
|
cuDNN : NO , but in your cmake file cuDNN is ON, but the system is not able to find the version required remaining all other say yes. I suspect this could be a potential problem causer? |
This is the runtime error:
This is the OpenCV configuration as printed from the program itself at run time. So this is the opencv being used. See below: cuDNN: YES (ver 8.0.0) Maybe the error is because of: Baseline: NEON FP16 in case the model is for 32bits and the engine is 16 bits? I think there is no doubt that the OpenCV has CUDA and has cuDNN.
|
@SaiSandeepKantareddy That's defnitely the problem. You need @tadam98 The assertion that is being triggered can only be triggered if the backend is set to |
See attached traces.
Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10
From: Yashas Samaga B L<mailto:notifications@github.com>
Sent: 27 May 2020 11:25
To: opencv/opencv<mailto:opencv@noreply.github.com>
Cc: tadam98<mailto:tadam_98@hotmail.com>; Mention<mailto:mention@noreply.github.com>
Subject: Re: [opencv/opencv] Compiling Opencv 4.2.0 + CUDA on jetson nano board (#16439)
@SaiSandeepKantareddy<https://github.com/SaiSandeepKantareddy> That's defnitely the problem. You need WITH_CUDA, WITH_CUDNN, WITH_CUBLAS and OPENCV_DNN_CUDA` set. Looking for lines that say "filtering out cuda4dnn source" in your CMake output. If you see this, it implies that the CUDA backend is not being built.
@tadam98<https://github.com/tadam98> The assertion that is being triggered can only be triggered if the backend is set to DNN_BACKEND_OPENCV. If you're trying to use the GPU, the script should have set the backend to DNN_BACKEND_CUDA and that assertion shouldn't have been triggered at all.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#16439 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AFBMCT2NM2765QYPLTUJJODRTTE7TANCNFSM4KLW76EA>.
|
@tadam98 I don't see any attachment in mail nor on GitHub. Maybe GitHub doesn't support attachments via mail. |
https://drive.google.com/folderview?id=1rotEOktKAFdQZhGJPr224A6aFpnZ3ubK
Try my google drive.
…________________________________
From: Yashas Samaga B L <notifications@github.com>
Sent: Wednesday, May 27, 2020 5:05:45 PM
To: opencv/opencv <opencv@noreply.github.com>
Cc: tadam98 <tadam_98@hotmail.com>; Mention <mention@noreply.github.com>
Subject: Re: [opencv/opencv] Compiling Opencv 4.2.0 + CUDA on jetson nano board (#16439)
@tadam98<https://github.com/tadam98> I don't see any attachment in mail nor on GitHub. Maybe GitHub doesn't support attachments via mail.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#16439 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AFBMCT2S7WBGPS7TJ2JLBRTRTUM3TANCNFSM4KLW76EA>.
|
|
make -j4
|
Okay, so what's the answer for it and how should I do get rid of the error on jetson nano? |
Hi, I have these flags on my cmake command line. Did I miss anything ?
|
This is my cmake run:
|
@tadam98 There are two conversations happening simultaneously in this issue. I am replying to two people. I don't know if you can see this in the mail. @tadam98 Do this and report what happens (on Jetson Nano):
As I told earlier, the assertion that fails can only happen when @SaiSandeepKantareddy Do you also have cuDNN 8? |
Hi,
Yes, cuDNN 8.0 is installed as part of NVIDIA Jetson JetPack DP 4.4. (DP=Developer pack).
I have used sdkmanager in CLI mode to ensure my image is “by the book” and it is.
(sdkmanager in gui mode does not come up with the Jetson Nano only with the Jetson Xavier)
cuDNN is installed and found by the OpenCV cmake.
It is found after a modification to cmake\FindCUDNN.cmake file because in CUDA 10.2 the cudnn version is not anymore in cudnn.h but moved to cudnn_version.h. The is also a problematic SET command that is not generation the correct version code. I did not dive into it, just changed it to work.
# extract version from the include
if(CUDNN_INCLUDE_DIR)
file(READ "${CUDNN_INCLUDE_DIR}/cudnn_version.h" CUDNN_H_CONTENTS)
set(CUDNN_VERSION
"${CUDNN_MAJOR_VERSION}.${CUDNN_MINOR_VERSION}.${CUDNN_PATCH_VERSION}")
# CACHE
# STRING
# "cuDNN version"
# )
Command line parameters (in a runme file):
python3 ssd_object_detection.py \
--prototxt MobileNetSSD_deploy.prototxt \
--model MobileNetSSD_deploy.caffemodel \
--input guitar.mp4 --output output.avi \
--display 0 --use-gpu 1
Log level output:
dlinano@dlinano:~/Downloads/pyimagesearch/opencv-dnn-gpu$ export OPENCV_LOG_LEVEL=INFO
dlinano@dlinano:~/Downloads/pyimagesearch/opencv-dnn-gpu$ ./runme
cv2 version= 4.2.0
cv2 path= /usr/local/lib/python3.6/dist-packages/cv2/python-3.6/cv2.cpython-36m-aarch64-linux-gnu.so
Traceback (most recent call last):
File "ssd_object_detection.py", line 43, in <module>
net = cv2.dnn.readNetFromTensorflow(args["model"],args["prototxt"])
cv2.error: OpenCV(4.2.0) /home/dlinano/Downloads/opencv/modules/dnn/src/tensorflow/tf_io.cpp:42: error: (-2:Unspecified error) FAILED: ReadProtoFromBinaryFile(param_file, param). Failed to parse GraphDef file: MobileNetSSD_deploy.caffemodel in function 'ReadTFNetParamsFromBinaryFileOrDie'
dlinano@dlinano:~/Downloads/pyimagesearch/opencv-dnn-gpu$
Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10
From: Yashas Samaga B L<mailto:notifications@github.com>
Sent: 28 May 2020 09:04
To: opencv/opencv<mailto:opencv@noreply.github.com>
Cc: tadam98<mailto:tadam_98@hotmail.com>; Mention<mailto:mention@noreply.github.com>
Subject: Re: [opencv/opencv] Compiling Opencv 4.2.0 + CUDA on jetson nano board (#16439)
@tadam98<https://github.com/tadam98> There are two conversations happening simultaneously in this issue. I am replying to two people. I don't know if you can see this in the mail.
@tadam98<https://github.com/tadam98> Do this and report what happens (on Jetson Nano):
1. export OPENCV_LOG_LEVEL=INFO and run the script in the same terminal. Report what you get on the terminal output.
2. What arguments did you pass to the python script?
As I told earlier, the assertion that fails can only happen when DNN_BACKEND_OPENCV is being used. We need to figure out why it's happening.
@SaiSandeepKantareddy<https://github.com/SaiSandeepKantareddy> Do you also have cuDNN 8?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#16439 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AFBMCTZ327BYVXPJUF4QTN3RTX5IBANCNFSM4KLW76EA>.
|
I ran it again from the command line as the export may have not applied when I used the batch file.
|
I have installed Jetson pack 4.4 and it says it contains cuDNN but I am not able to find, I think @tadam98 has rightly pointed about the error in his previous comments about cudnn_version.h |
Correct. You must change OpenCV/cmake/FindCUDNN.cmake as I described in earlier posts. The corrections are needed because NVIDIA changed the location of the header files in cuda 10.2 which is part of Jetpack DP4.4.
Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10
From: SaiSandeepKantareddy<mailto:notifications@github.com>
Sent: 28 May 2020 15:36
To: opencv/opencv<mailto:opencv@noreply.github.com>
Cc: tadam98<mailto:tadam_98@hotmail.com>; Mention<mailto:mention@noreply.github.com>
Subject: Re: [opencv/opencv] Compiling Opencv 4.2.0 + CUDA on jetson nano board (#16439)
@tadam98<https://github.com/tadam98> There are two conversations happening simultaneously in this issue. I am replying to two people. I don't know if you can see this in the mail.
@tadam98<https://github.com/tadam98> Do this and report what happens (on Jetson Nano):
1. export `OPENCV_LOG_LEVEL=INFO` and run the script in the same terminal. Report what you get on the terminal output.
2. What arguments did you pass to the python script?
As I told earlier, the assertion that fails can only happen when DNN_BACKEND_OPENCV is being used. We need to figure out why it's happening.
@SaiSandeepKantareddy<https://github.com/SaiSandeepKantareddy> Do you also have cuDNN 8?
I have installed Jetson pack 4.4 and it says it contains cuDNN but I am not able to find, I think @tadam98<https://github.com/tadam98> has rightly pointed about the error in his previous comments about cudnn_version.h
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#16439 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AFBMCT7OO23XRR7MIKN74UDRTZLELANCNFSM4KLW76EA>.
|
@SaiSandeepKantareddy Please have a look at #17238. NVIDIA hasn't released the documentation or release notes for cuDNN 8. We don't know for sure how exactly the new cuDNN 8 structures the headers and binaries. The fix might be a bit more complicated based on the comments in the aforementioned PR. |
Actually, it is working on jetson pack 4.3
…On Thu, 28 May 2020, 18:49 Yashas Samaga B L, ***@***.***> wrote:
@SaiSandeepKantareddy <https://github.com/SaiSandeepKantareddy> Please
have a look at #17238 <#17238>.
NVIDIA hasn't released the documentation or release notes for cuDNN 8. We
don't know for sure how exactly the new cuDNN 8 structures the headers and
binaries. The fix might be a bit more complicated based on the comments in
the aforementioned PR.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#16439 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AD3UKTK5IBCJUOENY7RQ3ILRTZQGNANCNFSM4KLW76EA>
.
|
Hi, I can confirm a successful compilation of OpenCV 4.2.0 with CUDA (10.0) and cuDNN (7.6.3) that come with JetPack 4.3 with my software. Backend support is there and working. NVIDIA - do something about Jetpack DP4.4 and libcudnn.so.8 and also put OpenCV 4.2.0 rather than old versions compiled without any cuda or cudnn support. |
Hey YashasSamaga I've tried running your script, on the latest Jetson Nano .img release with JP4.4.1, and I am getting an error regarding openGL, saying that it is deprecated. I am not quite sure how to pull that part out of your script. Best regards |
|
@YashasSamaga |
Hi.
I have carefully followed the below link in order to install the OpenCV with CUDA support on the jetson nano board. but after a successful compile and I run my yolov3 object detection code BUT the application is still running on CPU only instead of GPU.
https://github.com/JetsonHacksNano/buildOpenCV/blob/master/buildOpenCV.sh
Since I am a beginner I was struggling to configure my code to run/use GPU so that I can get better FPS compared to CPU.
please help me, anyone, to get rid of this issue and share the updated procedure to compile OpenCV with CUDA support on jetson nano.
I believe this post will surely help a lot of users since there is no updated information on the internet about compiling the installing OpenCV 4.2.0/master branch version into the jetson nano board.
note:
I have run the Gpu graph app to check GPU usage percentage.
The text was updated successfully, but these errors were encountered: