NVIDIA JETSON ORIN
NVIDIA Jetson AGX Orin modules deliver up to 275 TOPS of AI performance with power configurable between 15W and 60W. This gives you up to 8X the performance of Jetson AGX Xavier in the same compact form factor. Jetson AGX Orin is available in 64GB and 32GB versions.
PyTorch and torchvision
PyTorch Geometric is a library for deep learning on irregular input data such as graphs, point clouds, and manifolds. Torch vision library is part of the PyTorch project. PyTorch is an open source machine learning framework.
YOLOv7
YOLOv7 is the fastest and most accurate real-time object detection model for computer vision tasks.
Installing pytorch and torchvision
Clone YOLOv7 repo and run test code
If you don,t have python in your system then you can install python following our previous article. Installing pytorch and torchvision in jetson orin is not straightforward as that of our desktop computer or laptop. This is because embedded device usually has arm processor. In order to run YOLOv7 github repo code https://github.com/WongKinYiu/yolov7 , pytorch and torch vision is needed. You can clone the project to the folder and run required library using requirement.txt file.
git clone https://github.com/WongKinYiu/yolov7
Install all python libraries using command:
pip3 install -r requirements.txt
Run detect code to test dependencies.
python detect.py --weights yolov7.pt --conf 0.25 --img-size 640 --source inference/images/horses.jpg
Code run successfully but CPU is used which is seen clearly in figure below. You can also check using python by importing torch and checking cud available command.
>>> import torch
>>> torch.cuda.is_available()
False
When visualizing the torch and torch vision command pip list following version is shown at the time of this article writing.
Install Cuda supported library for jetson orin
We have to install separate torch and torch vision libraries. For this we need to install prerequisite libraries and jetpack. By this time latest torch version and torch vision supported by https://pypi.org/project/torchvision/ were 1.13 & 0.14. We are installing torch version 1.11. For this download the whl file using website https://nvidia.box.com/shared/static/ssf2v7pf5i245fk4i0q926hy4imzs2ph.whl from nvidia built for jetson devices. We can also install 1.12 using https://developer.download.nvidia.com/compute/redist/jp/v50/pytorch/torch-1.12.0a0+2c916ef.nv22.3-cp38-cp38-linux_aarch64.whl.
After that install torch using command below.
pip3 install torch-1.11.0-cp38-cp38-linux_aarch64.whl
After that we have to install torch vision version supported by 1.11. For this we have to clone and install tochvision from git hub repo using command below. For 1.12 version torch vision branch should be v0.13.0
git clone --branch v0.12.0 https://github.com/pytorch/vision torchvision
cd tochvision
pip3 uninstall torhvision
python3 setup.py install --user
Finally you can see the yolov7 running smoothly using GPU.
The purpose of making this tutorial is because, this issues could be headache for developer when working on projects.