Skip to content

cloudpark93/yolov5-jetson-nano-tips-errors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YOLOv5 on Jetson Nano Tips and Errors 🍕

This is to share some tips and my personal experinece to solve errors when installing YOLOv5 on Jetson Nano.

For anyone who would like to begin with "How to install YOLOv5 on Jetson Nano", please search it in google.

There are tons of githubs and blogs which kindly give you the instructions on "how to install YOLOv5 on Jetson Nano" in google.


Tip 1: Python version 😊

The requirement for Python version is >= 3.7.0, but YOLOv5 actaully works with the pre-installed Python 3.6.9.

  • When you use pre-installed Python 3.6.9, you are recommended to use pip3 install command to install libraries.

You can see that YOLOv5 on Jetson Nano works with Python 3.6.9 in the images below!

Tip 2: OpenCV compile 🤢

I tried to utilize the pre-installed opencv-python, but it kept giving me some errors.

For the ease of operation without trivial errors, I recommend you to install OpenCV in your Jetson Nano.

We all know that it is super annoying to install OpenCV in Ubuntu.

Surprisingly, Q-engineering has kindly shared his technology to build OpenCV very easily.

Just click the link above, and follow his perfect instructions!

Things to be careful when installing OpenCV:

  • OpenCV version 4.5.2: You need more memory for the version 4.5.2. Hence, you need to edit two files.

    • /sbin/dphys-swapfileCONF_MAXSWAP=4096 (this is only for OpenCV 4.5.2)
    • /etc/dphys-swapfileCONF_SWARSIZE=4096 (this is only for OpenCV 4.5.2)
  • OpenCV version other than 4.5.2: You only need to edit one file.

    • /etc/dphys-swapfileCONF_SWARSIZE=4096 (this is only for OpenCV version other than 4.5.2)
  • Once your build is successfully completed, you can see from jtop that OpenCV has been successfully compiled with CUDA.

Tip 3: Change requirements.txt in yolov5 folder 😘

In my case, I uninstalled opencv-python. However, when running the yolov5 (detect.py), it kept installing the opencv-python and this eventually caused errors.

Therefore, I commented out opencv-python line in the requirements.txt file.

  • opencv-python>=version → # opencv-python>=version

Tip 4: Change camera screen frame size for real-time detection 😜

Some of you guys may suffer from larger screen frame than the size of the monitor.

I suffered as I am using a mini monitor for Jetson Nano (check the image below).

In this case, you can simply resolve this matter by checking the supported frame sizes of the camera, and add two more lines under the class LoadStreams: in datasets.py file.

For your information, the location of datasets.py is yolov5 → utils → datasets.py

yolov5/
│   ...
└───utils/
    │   datasets.py
    │   ...
  1. I uploaded the edited datasets.py in this repository! Please read the followings before you use it! 🙃

  2. Check the supported frame sizes of the camera in the terminal.

    • v4l2-ctl --list-formats-ext
    • You can see that the supported frame sizes are various such as 640(width)x480(height), 800(w)x600(h) etc.

  1. Add two more lines under the class LoadStreams: in datasets.py file.

    • Make sure to add only the supported frame sizes!
    • int(cap.set(cv2.CAP_PROP_FRAME_WIDTH, supported width value))
    • int(cap.set(cv2.CAP_PROP_FRAME_HEIGHT, supported height value))

  1. If you add any unsupported values of width and height, you will receive GStreamer warning like the image below.

  1. Save the changes, and run YOLOv5 to check the frame size.


Error 1: opencv illegal instructions (core dumped) 😑

  1. Open the .bashrc file in the terminal: sudo vi ~/.bashrc or sudo nano ~/.bashrc

  2. Add export OPENBLAS_CORETYPE=ARMV8 at the bottom of the .bashrc file, and save/exit.

  3. Type source ~/.bashrc in the terminal to apply the setting without rebooting the system.

Error 2: user warning: failed to load image python extension 😑

Try to downgrade your torch and torchvision versions.

Please check the compatible torch and torchvision versions in the Nvidia developer forum.

Go to the link attached above, click Installation, then you can see the compatible versions as below:

In my case, I installed torch 1.7.0 and torchvision 0.8.1, and did not get the error anymore.

Error 3: The_imagingft C module is not installed 😑

This is because your PIL has been compiled without libfreetype.

Try the following commands in the terminal.

sudo apt-get install libfreetype6-dev

sudo pip3 uninstall pillow

sudo pip3 install Pillow==7.1.2

  • I used pip3 because I am using python3.

co-researcher

Please visit my co-researcher's github as well!
https://github.com/jinsoo9595

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published