How to install Yolo v4 on Jetson Xavier NX
In this tutorial, we will see how to use Jetson Xavier NX with YOLO v4 and darknet. In the past, we have already talked about the Nvidia system module and for comparison or simple curiosity, I invite you to read and watch the YOLO V3 – Install and run Yolo on Nvidia Jetson Nano (with GPU) video.
Jetson Xavier NX technical details
When dealing with Computer vision, the first most important feature is the graphics card:
GPU: NVIDIA Volta with 384 CUDA Cores, 48 Tensor Cores
Given its size, the power consumption, and the cost that on the Nvidia store is $ 399 make it an excellent product for specific projects, especially when we cannot use a Supercomputer. I show you a table with the most important technical details but I recommend you visit the official Jetson Xavier NX Nvidia page
|GPU||384-core NVIDIA Volta™ GPU with 48 Tensor Cores|
|CPU||6-core NVIDIA Carmel ARM®v8.2 64-bit CPU 6 MB L2 + 4 MB L3|
|Memory||8 GB 128-bit LPDDR4x 51.2GB/s|
|Storage||microSD (Card not included)|
|VIDEO ENCODER||2x 4Kp30 | 6x 1080p 60 | 14x 1080p30 (H.265/H.264)|
|VIDEO DECODER||2x 4Kp60 | 4x 4Kp30 | 12x 1080p60 | 32x 1080p30 (H.265) 2x 4Kp30 | 6x 1080p60 |16x 1080p30 (H.264)|
|Connectivity||Gigabit Ethernet, M.2 Key E (WiFi/BT included), M.2 Key M (NVMe)|
|Camera||2x MIPI CSI-2 D-PHY lanes|
|Display||HDMI and DP|
|Others||GPIOs, I2C, I2S, SPI, UART|
|Mechanical||69.6 mm x 45 mm | 260-pin SO-DIMM connector|
|AI Perf||21 TOPS|
|POWER||10W | 15W|
|PCIe||1 x1 (PCIe Gen3) + 1 x4 (PCIe Gen4)|
|CSI Camera||Up to 6 cameras (24 via virtual channels) | 14 lanes (3×4 or 6×2) MIPI CSI-2 | D-PHY 1.2 (up to 30 Gbps)|
|DL Accelerator||2x NVDLA Engines|
|VISION ACCELERATOR||7-Way VLIW Vision Processor|
|Networking||10/100/1000 BASE-T Ethernet|
Install Yolo v4 on Jetson Xavier NX
The goal of this tutorial is to install YOLOv4 on Nvidia Jetson Xavier NX and run it in real-time. I will not delve into the aspects of installing the operating system in the MicroSD but I will leave you some links to find the correct JetPack.
Where can i find the JetPack and how do i use it?
This is the JetPack Archive page with the complete archive, I recommend you download the latest available.
Just downloaded you have to write the image in the MicroSD card and this Getting Started With Jetson Xavier NX Developer Kit page can help you.
If the MicroSD card is ready you can put it in the device and follow these instructions How to Install JetPack for the first installation, this is the result at startup.
Download, Install and Run Darknet
For this object detection project, we will use Darknet which is the framework on which to use the Yolo v4 deep learning algorithm. Now open the terminal and run the commands step by step.
sudo apt-get update
2 EXPORT CUDA PATH
After checking for updates we have to copy, one at a time, the commands for export CUDA path.
As you can see from the image, the command produces no output
3 INSTALL DARKNET
We download darknet from GitHub always through the terminal
git clone https://github.com/AlexeyAB/darknet
When the download finishes you will find a new folder called Darknet.
Access to the folder through the terminal
If it looks like it is in the terminal, everything went as it should and you are inside the folder.
Now let’s run the commands to download the model.
4 ENABLE GPU
This is the most important step, we need to enable the GPU and then take advantage of the full power of the graphics card of this device. Also from the terminal execute the command
sudo vi Makefile
through the VIM editor you need GPU, CUDNN, OpenCV. The result must be as in the image.
Now I have pressed Esc + shift + z + z to save.
The last step, we need to fill out. Always in the darknet folder from the terminal, we execute the command
Hopefully, it should fill out in a few minutes and we’re ready to test.
Run YOLO v4 from a video
To test with YOLO v4 I downloaded a video called jump_water.mp4 and put it in the Darknet folder. Now run this command to start processing
./darknet detector demo cfg/coco.data cfg/yolov4-csp.cfg yolov4-csp.weights -ext_output jump_water.mp4
After loading yolo model on the memory, this is the result
Run YOLO v4 from a camera
Now let’s try to execute the command to start Yolo in realtime with the camera
./darknet detector demo cfg/coco.data cfg/yolov4-csp.cfg yolov4-csp.weights -c 0