文章目录
前言
前面编写了一篇文章,描述在Ubuntu20.04.2系统采用python3.10.6安装tensorflow的过程,当时根据前辈的文章选择在虚拟环境中安装,这样的好处就是不会对工作环境产生影响。本文安装pytorch采用直接在python中安装,主要考虑后期主要用pytorch框架来工作。但是为了学习RK3588的RKNN-Toolkit2需要tensorflow/torch/torchvision/opencv-python/onnx这些依赖,我在虚拟环境中pytorch再安装一遍。
一、pytorch安装
首先进入pytorch官方网页:https://pytorch.org/。根据自身系统、打包方式、语言和硬件情况,官网会生成下载的命令。
将红框内的命令输入bash。
pi@NanoPi-R6S:/opt$ pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
#整个过程安装还算顺利,出现1个warning:
WARNING: The scripts convert-caffe2-to-onnx, convert-onnx-to-caffe2 and torchrun are installed in '/home/pi/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
#安装结果:
Successfully installed torch-1.13.1 torchaudio-2.0.0 torchvision-0.1.6 typing-extensions-4.4.0
二、pytorch安装检验
进入python命令行,验证pytorch是否可以导入:
pi@NanoPi-R6S:/opt$ python3
Python 3.10.6 (main, Mar 10