NVIDIA Jetson Xavier NX安装torch和torchvision

news/2025/3/12 12:18:25/

文章目录:

  • 1 安装torch
  • 2 安装torchvision
    • 2.1 方法一:直接源码安装torchvision
    • 2.2 方法二:使用pip3安装torchvision

1 安装torch

1、教程地址
安装torch直接参考官方的教程即可,官方教程地址:

Jetson_Zoo教程地址:https://www.elinux.org/Jetson_Zoo

2、下载torch安装包

下载torch1.6.0版本的whl安装包,下载地址如下:

torch1.6.0版本下载地址:https://nvidia.box.com/shared/static/9eptse6jyly1ggt9axbja2yrmj6pbarc.whl

其他版本自己去上面的官网地址查看那

3、下面是安装torch的具体过程

# install OpenBLAS and OpenMPI
$ sudo apt-get install libopenblas-base libopenmpi-dev# Python 2.7 (download pip wheel from above)
$ pip install future torch-1.4.0-cp27-cp27mu-linux_aarch64.whl# Python 3.6 (download pip wheel from above)
$ sudo apt-get install python3-pip
pip3 install Cython
pip3 install numpy torch-1.6.0-cp36-cp36m-linux_aarch64.whl

2 安装torchvision

2.1 方法一:直接源码安装torchvision

1、查看torchvision和torch的版本对应关系

首先安装torchvision的版本是要和torch版本对应的,具体对应如下:

在这里插入图片描述

2、直接使用pip3安装torchvision(报错)

如果你直接安装,会提示你没有0.7.0的版本,而且提示的版本都比较低:

zhihui@zhihui-desktop:~$ pip3 install torchvision==0.7.0
Collecting torchvision==0.7.0Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.tuna.tsinghua.edu.cn', port=443): Read timed out. (read timeout=15)",)': /simple/torchvision/Could not find a version that satisfies the requirement torchvision==0.7.0 (from versions: 0.1.6, 0.1.7, 0.1.8, 0.1.9, 0.2.0, 0.2.1, 0.2.2, 0.2.2.post2, 0.2.2.post3)
No matching distribution found for torchvision==0.7.0
zhihui@zhihui-desktop:~$ 

3、正确安装torchvision的方式

  • 克隆仓库

git clone -b v0.7.0 https://hub.fastgit.org/pytorch/vision.git

zhihui@zhihui-desktop:~$ git clone  -b v0.7.0 https://hub.fastgit.org/pytorch/vision.git
Cloning into 'vision'...
remote: Enumerating objects: 30, done.
remote: Counting objects: 100% (30/30), done.
remote: Compressing objects: 100% (30/30), done.
remote: Total 11381 (delta 7), reused 2 (delta 0), pack-reused 11351
Receiving objects: 100% (11381/11381), 12.75 MiB | 965.00 KiB/s, done.
Resolving deltas: 100% (7922/7922), done.
Note: checking out '78ed10cc51067f1a6bac9352831ef37a3f842784'.You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:git checkout -b <new-branch-name>zhihui@zhihui-desktop:~$ ls
datsets  Desktop  Documents  Downloads  examples.desktop  Music  Pictures  project  Public  Templates  tools  Videos  vision
  • 编译安装torchvision

cd vision
python3 setup.py install

zhihui@zhihui-desktop:~$ cd vision/
zhihui@zhihui-desktop:~/vision$ ls
cmake           CODE_OF_CONDUCT.md  examples    LICENSE      mypy.ini   README.rst  setup.cfg  test         tox.ini
CMakeLists.txt  docs                hubconf.py  MANIFEST.in  packaging  references  setup.py   torchvision  travis-scripts
zhihui@zhihui-desktop:~/vision$ python3 setup.py install

如果上面安装报错:fatal error: libavcodec/avcodec.h: No such file or directory,请参考博客

2.2 方法二:使用pip3安装torchvision

1、首先使用查看有哪些torchvision版本

pip3 search torchvision --timeout=500

zhihui@zhihui-desktop:~$ pip3 search torchvision --timeout=500
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f843ca400>: Failed to establish a new connection: [Errno 101] Network is unreachable',)': /pypi
torchvision-raspi (0.2.1.1)                      - Torchvision for Raspberry Pi 3B armv7l
torchvision-enhance (0.1.3)                      - Enhance torchvision for multi-channel images, 16-bit image, segmentation...
torchvision (0.8.1)                              - image and video datasets and models for torch deep learningINSTALLED: 0.7.0a0+78ed10cLATEST:    0.8.1
opencv-torchvision-transforms-yuzhiyang (0.0.1)  - an opencv based rewriting of the "transforms" in torchvision package
nvidia-torchvision (0.0.1.dev4)                  - A fake package to warn the user he is not installing the correct package.
torchvision-yolov3 (0.6.0)                       - A minimal PyTorch implementation of YOLOv3.
torchvision-detection (0.7.0)                    - Object detection reference training scripts.
torchvision4ad (0.1.1)                           - torchvision for anomaly detection
pytorch-fasterrcnn (0.2.1)                       - Torchvision Faster RCNN Fine Tuner
lxtoolkit (0.0.1)                                - a simple toolkit based on torch and torchvision
quadratum (0.2.1)                                - Additional torchvision image transforms for practical usage.
opencv-transforms (0.0.3.post3)                  - A drop-in replacement for Torchvision Transforms using OpenCV
invertransforms (0.2.1)                          - A library which turns torchvision transformations invertible and replayable.
zhihui@zhihui-desktop:~$ 

2、查看到有torchvision的0.7.0a0+78ed10c,这个就是0.7.0版本,安装这个就可以

pip3 install torchvision==0.7.0a0+78ed10c

pip3

参考:https://blog.csdn.net/weixin_43877080/article/details/106994966
参考:https://blog.csdn.net/qq_37301003/article/details/107139218

欢迎大家关注笔者,你的关注是我持续更博的最大动力


原创文章,转载告知,盗版必究

微信:suihailiang0816
QQ:931762054
wx公众号:仰望星空的小随

http://www.ppmy.cn/news/431246.html

相关文章

Jetson Xavier NX相关安装

安装jtop sudo apt-get install python3-pip sudo -H pip3 install -U jetson-stats sudo jtop 更换镜像源 deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports…

Jetson Xaiver NX相关教程(详细版)

一、参考资料 Jetson nano/NX 部署Yolo v5过程记录 二、相关介绍 三、软件安装 2.1 jetson-stats 2.1.1 相关介绍 jetson-stats是一个开源软件包&#xff0c;用于监测和控制Nvidia Jetson设备的运行状态。 Jetson-stats包含以下工具&#xff1a; jtop jetson_config jetso…

NXOpen相关

网上文档 可以搜索GTAC&#xff0c;进入相应版本的NX Documentation. 其中Product area下面的Programming Tools包含了NXOpen开发相关的信息。如要本地查看需要下载。 进入NX Open模块。进入Open for C/C: Open C Reference Guide 内部包含了C语言API。包括各种调用NX模块的函…

NX-API简介

来源&#xff1a;https://developer.cisco.com/learning/lab/nxos-intro-03_nxapi-rest/step/1 了解更多&#xff1a;https://developer.cisco.com/site/cisco-nexus-nx-api-references/ 概观 在Cisco Nexus设备中&#xff0c;最常用的配置方法是使用仅在设备上运行的命令行界…

Xavier NX实现硬解码H264H265

提示&#xff1a;文章写完后&#xff0c;目录可以自动生成&#xff0c;如何生成可参考右边的帮助文档 文章目录 前言一、NX的硬解码&#xff1f;二、测试代码三、软硬解对比四、总结 前言 最近在做一个项目&#xff0c;使用opencv的VideoCapture拉流并把帧送进模型推理&#x…

边缘检测卷积核矩阵

边缘检测卷积核矩阵 Sobel 算子&#xff1a; Sobel 算子是一种常用的边缘检测算子&#xff0c;其卷积核矩阵如下&#xff1a; Copy code Gx | -1 0 1 | Gy | -1 -2 -1 || -2 0 2 | | 0 0 0 || -1 0 1 | | 1 2 1 |其中 Gx 表示水平方向的…

Portraiture4最新版滤镜P图一键磨皮插件

今天coco玛奇朵给大家带来了一款ps磨皮插件&#xff0c;超级简单好用。Portraiture 滤镜是一款 Photoshop&#xff0c;Lightroom 和 Aperture 插件&#xff0c;DobeLighttroom 的 Portraiture 消除了选择性掩蔽和逐像素处理的繁琐的手工劳动&#xff0c;以帮助您在肖像修整方面…

Portraiture宿主磨皮插件PS+Lr人像智能磨皮美化

Portraiture这是一款适用于PS和LR的磨皮滤镜插件&#xff0c;操作简便、省去了选择蒙版和逐步像素处理的繁琐流程&#xff0c;帮助您实现高效的肖像修饰。 Portraiture 特色功能 自动人脸检测 集成了先进人脸检测技术&#xff0c;能自动的识别脸部五官以及皮肤&#xff0c;包…