This article explains how to run YOLOv8 on the Jetson Nano. Pre-built PyTorch and TorchVision packages are used.
Install Jetpack 4.6 (L4T 32.6.1) on Jetson Nano in advance.
Install the required packages.
sudo apt update
sudo apt install -y python3.8 python3.8-venv python3.8-dev python3-pip \
libopenmpi-dev libomp-dev libopenblas-dev libblas-dev libeigen3-dev libcublas-dev
Code language: Bash (bash)
Clone the YOLOv8 repository.
git clone https://github.com/ultralytics/ultralytics
cd ultralytics
Code language: Bash (bash)
Create a Python 3.8 virtual environment using venv.
python3.8 -m venv venv
source venv/bin/activate
Code language: Bash (bash)
Update Python packages not specified in YOLOv8.
pip install -U pip wheel gdown
Code language: Bash (bash)
Download and install the pre-built PyTorch, TorchVision package. This package was built using the method described in this article. This article also uses the pre-built package.
# pytorch 1.11.0
gdown https://drive.google.com/uc?id=1hs9HM0XJ2LPFghcn7ZMOs5qu5HexPXwM
# torchvision 0.12.0
gdown https://drive.google.com/uc?id=1m0d8ruUY8RvCP9eVjZw4Nc8LAwM8yuGV
python3.8 -m pip install torch-*.whl torchvision-*.whl
Code language: Bash (bash)
Install the Python package for YOLOv8.
pip install .
Code language: Bash (bash)
Execute object detection.
yolo task=detect mode=predict model=yolov8n.pt source=0 show=True
yolo task=segment mode=predict model=yolov8n-seg.pt source=0 show=True
Code language: Bash (bash)
Note that for object detection, tasks=detect displays bounding boxes, and tasks=segment displays bounding boxes and segmentation.
YOLOv8 has several models (yolov8n, yolov8s, yolov8m, yolov8l, yolov8x), and the following are the actual FPS when running on Jetson Nano.
detect | segment | |
yolov8n | 6.1 | 4.2 |
yolov8s | 3.1 | 2.2 |
yolov8m | 1.3 | 0.96 |
yolov8l | 0.77 | 0.61 |
yolov8x | 0.48 | 0.38 |
Thank you for reading! If you found this article valuable and would like to support it, consider becoming a sponsor through GitHub Sponsors. Your support will help me continue to produce high-quality articles like this one. Every little bit truly helps and is greatly appreciated. Thank you in advance for considering to sponsor my work.