Build OpenCV with CUDA Support for Jetson

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello it's Jim from jetsonhacks.com today we are going to build a Cuda enabled version of opencv for Jetson one of the things you may have noticed is that if you look at the default opencv installation on your Jetson it is not Cuda enabled in this video we are aiming to fix that one of the Jetson experts in the community Michael degance has a script which will build opencv from source with Cuda support let's close this up in the empty const repository on GitHub there is a repository named Nano build opencv let's copy the address let's clone that Repository and switch over to that repositories directory now we open up the build script let's scroll down a little these are the dependencies we are going to install let's scroll down a little more here we have the opencv build options they are stored as cmake Flags which are passed to the compiler let's take a look at the opencv documentation we'll open up another web browser we are working with the 4.5.4 release opencv tutorials introduction to opencv and then opencv configuration options reference this is the documentation page for all of the build options for opencv there is an extensive list as there are very many options to build opencv it's from this documentation that we figure out what the cmake flags should be for example here's the flag to turn on Cuda support one flag of notice the Cuda Arch Bend flag this is a list of GPU architectures which this build will support in this case it is all the Jetsons tx1 Nano tx2 Xavier and orins if you remember the build machine has an architecture of 7.2 which is a Xavier you can modify the list to build opencv for just one specific architecture this will reduce the build time and size of the resulting Library also we will need to change the CU DNN version to match the jetpack release for which we are building in this case the library version is 8.6 let's change that save everything and close it up enough talk let's start building we can specify the opencv version on the command line let's go for a 4.5.4 and we are off to the races the build takes a long time a Jetson Nano it takes 8 to 12 hours depending on the build configuration of course on a agx orange it takes a lot less time we need to type in the password for system install password and off we go to the install one more question the build files are in the slash TMP directory you can remove them if you want however I keep them around in case I want to rebuild opencv that way I don't have to recompile the world from scratch installation complete let's switch tabs back to jtop we'll need to restart jtop let's switch over to the info tab we see that opencv 4.5.4 is installed with Cuda let's open up the file browser the build files are in the slash TMP directory they are in the build underscore opencv directory let's put them in the home directory for now when we switch over to the home directory there they are let's go back over to the home directory let's figure out how big this puppy is we'll check out the folder properties 1.7 gigabytes let's see what python has to say about this let's import opencv the opencv module is named CV2 now let's get the opencv build information that went by just fast enough not to be able to read it let's scroll up a ways this gives us all the opencv build information version 4.5.4 here are all the different media and video libraries included in the build and here's the good stuff we have good installed all of the Jetson GPU architectures are supported in this build red dog red dog 53 62 72 87 hike and we also support CU DNN it's demo time for our demo today we are going to use a deep neural network the DNN does face detection it's located in the opencv zoo I've cloned the opencv Zool ready I have modified the demo to better fit to the capabilities of the USB camera that I'm using let's take a look at those changes let's open up jtop so that we can monitor the GPU usage now let's launch the demo without Cuda support there I am let's move this up here okay we see that we are getting FPS somewhere in these 17 to 20 range this is only using the CPU let's take a look at the CPU they appear to be pretty busy let's switch back over there let's look at a Nobel Prize winner that's pretty good it's pretty uh performance the FPS counter moves around quite a bit but when you'll see it in person it looks pretty smooth but it's not great let's take a look at the Cuda version let's grab this line it has a secret incantation on it these flags tell opencv to use Cuda why here I am again you can see that the frame rate jumped up looks like it's in the 50-ish range 55 45 somewhere in there you can see a lot more of the GPU is being used let's take a look at our CPU usage oh they calmed down quite a bit so they about cut in half you can see that we get GPU usage kind of moves around a little bit let's take a look at our Nobel Prize winner see if they're still there yes they are it's a little bit of work to get opencv working on Cuda however if you need the performance boost it's well worth it but just make sure before you start if you have a specific application that it is Cuda enabled in the opencv library hey if you got this far you might as well like the video and if you have not already please subscribe it helps the channel immensely at least that's what the other YouTube channels say thanks for watching [Music] foreign [Music]
Info
Channel: JetsonHacks
Views: 23,337
Rating: undefined out of 5
Keywords: Jetson TX1, Jetson TX2, Jetson Nano, Jetson Xavier, Jetson Orin, OpenCV, NVIDIA Jetson, Jetson Orin Nano, Jetson Orin NX, Jetson AGX Orin, Jetson Xavier NX, Jetson AGX Xavier
Id: art0-99fFa8
Channel Id: undefined
Length: 8min 31sec (511 seconds)
Published: Fri Mar 17 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.