当前jetpack版本为5.1.1,对应的torch为1.14.0版本,torchvision版本为0.14.1,CUDA版本为11.4.315.opencv with cuda 版本4.5.4,tensorrt版本5.1.1。pytorch1.12.0 torchvision0.13.0
具体对应关系查看https://forums.developer.nvidia.com/t/pytorch-for-jetson/72048
安装步骤参考:https://blog.csdn.net/xwb_12340/article/details/135107394?spm=1001.2014.3001.5502
1)更新设备
sudo apt update
sudo apt install -y python3-pip
pip3 install --upgrade pip
2)注释掉torch和torchvision,后面单独安装。当前目录为readme目录
cd ./ultralytics
注释掉requirements.txt中的
#torch>=1.8.0
#torchvision>=0.9.0
3)安装依赖库
sudo apt install -y libfreetype6-dev
sudo pip3 install -r requirements.txt -i https://pypi.douban.com/simple
4)安装torch
从https://forums.developer.nvidia.com/t/pytorch-for-jetson/72048下载对应的torch文件
sudo apt-get install python3-pip libopenblas-base libopenmpi-dev libomp-dev
sudo pip3 install torch-1.14.0a0+44dac51c.nv23.02-cp38-cp38-linux_aarch64.whl
apt-get install libjpeg-dev zlib1g-dev libpython3-dev libavcodec-dev libavformat-dev libswscale-dev
git clone --branch v0.14.1 https://bgithub.xyz/pytorch/vision.git torchvision
cd torchvision
sudo python3 setup.py install
6)验证torch和torchvision
>>> import torch
>>> print(torch.__version__)
>>> print('CUDA available: ' + str(torch.cuda.is_available()))
>>> print('cuDNN version: ' + str(torch.backends.cudnn.version()))
>>> a = torch.cuda.FloatTensor(2).zero_()
>>> print('Tensor a = ' + str(a))
>>> b = torch.randn(2).cuda()
>>> print('Tensor b = ' + str(b))
>>> c = a + b
>>> print('Tensor c = ' + str(c))
pip3 list,有如下信息表示安装torchvision成功
torchvision 0.16.1+fdea156
>>> import torchvision
>>> print(torchvision.__version__)
7)安装yolov8。当前目录为readme目录
安装onnx:
pip3 install onnx-graphsurgeon -i https://pypi.douban.com/simple
cd ./ultralytics
pip3 install .
yolo predict model=/home/nvidia/ultralytics/yolov8n.pt source=0 show=true