参考:玩转NVIDIA Jetson (25)— jetson 安装pytorch和torchvision
我的jeston信息:
torch install
安装环境
conda create -n your_env python=3.8
conda activate your_env
pytorch_for_jeston
安装.whl
文件
验证:
import torch
print(torch.__version__)
import torch报错ImportError: libopenblas.so.0: cannot open shared object file: No such file or directo
NVIDIA Jetson NX安装torchvision教程
sudo apt-get install libjpeg-dev zlib1g-dev libpython3-dev libavcodec-dev libavformat-dev libswscale-dev
https://github.com/pytorch/vision
git clone --branch v0.13.0 https://github.com/pytorch/vision/torchvision
torchvision install
选择对应版本:
离线下载网址:torchvision离线包
pip install xxxx.whl
验证:
import torchvision
print(torchvision.__version__)
>>> print(torchvision.__version__)
0.13.0
出现警告:
import torchvision
/home/nvidia/.conda/envs/env_name/lib/python3.8/site-packages/torchvision/io/image.py:13: UserWarning: Failed to load image Python extension:
warn(f"Failed to load image Python extension: {e}")
try1:
pip install 'pillow<7'
# 不兼容
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
matplotlib 3.7.5 requires packaging>=20.0, which is not installed.
pip uninstall matplotlib
pip install 'pillow<7'
(env_name) nvidia@nvidia-desktop:~/Downloads$ pip list
Package Version
----------------------- -----------------------
absl-py 2.1.0
cachetools 5.5.0
certifi 2024.8.30
charset-normalizer 3.3.2
contourpy 1.1.1
cycler 0.12.1
filelock 3.16.1
fonttools 4.54.0
fsspec 2024.9.0
google-auth 2.35.0
google-auth-oauthlib 1.0.0
grpcio 1.66.1
idna 3.10
importlib_metadata 8.5.0
importlib_resources 6.4.5
Jinja2 3.1.4
joblib 1.4.2
kiwisolver 1.4.7
loguru 0.7.2
Markdown 3.7
MarkupSafe 2.1.5
mpmath 1.3.0
networkx 3.1
numpy 1.24.4
oauthlib 3.2.2
Pillow 6.2.2
pip 24.2
protobuf 5.28.2
ptflops 0.7.3
pyasn1 0.6.1
pyasn1_modules 0.4.1
pycairo 1.26.1
PyGObject 3.48.2
pygst 0.0.4
pyparsing 3.1.4
python-dateutil 2.9.0.post0
requests 2.32.3
requests-oauthlib 2.0.0
rsa 4.9
scikit-learn 1.3.2
scipy 1.10.1
setuptools 74.1.2
six 1.16.0
sympy 1.13.3
tensorboard 2.14.0
tensorboard-data-server 0.7.2
thop 0.1.1.post2209072238
threadpoolctl 3.5.0
torch 1.12.0a0+2c916ef.nv22.3
torchvision 0.13.0
traitlets 5.14.3
typing_extensions 4.12.2
urllib3 2.2.3
Werkzeug 3.0.4
wheel 0.44.0
zipp 3.20.2
pip3 install torchvision==0.13.0
Downloading torchvision-0.13.0-cp38-cp38-manylinux2014_aarch64.whl (701 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 701.7/701.7 kB 7.2 MB/s eta 0:00:00
Installing collected packages: torchvision
Successfully installed torchvision-0.13.0
try2
但是我的版本是对的,但是只是个警告 ignore it
import torch不出错,但是import torchvision报错:UserWarning: Failed to load image Python extension: Could not
Verification
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))
Build from Source
…
Note on Upgrading pip
…