NANO安装pytorch-yolov5

注意:1.python版本不需要一开始就升级
2.升级并更改后的python3.8,可能无法pip安装torch
3.在requirements.txt中与torch有关的,视情况而定注释掉
4.多试几次!!!!
5.考虑python版本问题!!!
6.如需虚拟环境安装可参考本人好友的https://blog.csdn.net/weixin_43761828/article/details/117381527?spm=1001.2014.3001.5501

sudo apt install python3.8

nano内置好了cuda,但需要配置环境变量才能使用
打开命令行添加环境变量即可
我这里是cuda10.2大家要根据自己的cuda版本去填写路径

vi ~/.bashrc
export PATH=/usr/local/cuda-10.2/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-10.2/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
export CUDA_ROOT=/usr/local/cuda
source ~/.bashrc

查看是否配置成功

nvcc -V

更新pip

sudo apt-get install python3-pip python3-dev
python3 -m pip install

解决方法是更新 setuptools 和 pip:

pip install --upgrade setuptools

python -m pip install --upgrade pip

安装jtop库这个可以监控自己的设备cpugpu工作状态

sudo -H pip3 install jetson-stats
sudo jtop

配置需要用到的库

sudo apt-get install build-essential make cmake cmake-curses-gui
sudo apt-get install git g++ pkg-config curl
sudo apt-get install libatlas-base-dev gfortran libcanberra-gtk-module libcanberra-gtk3-module
sudo apt-get install libhdf5-serial-dev hdf5-tools 
sudo apt-get install nano locate screen

安装所需要的依赖环境

sudo apt-get install libfreetype6-dev 
sudo apt-get install protobuf-compiler libprotobuf-dev openssl
sudo apt-get install libssl-dev libcurl4-openssl-dev
sudo apt-get install cython3

安装opencv的系统级依赖,一些编解码的库:

sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install libxvidcore-dev libavresample-dev
sudo apt-get install libtiff-dev libjpeg-dev libpng-dev

下载torch-1.8.0-cp36-cp36m-linux_aarch64,位于

https://forums.developer.nvidia.com/t/pytorch-for-jetson-version-1-10-now-available/72048

sudo apt-get install python3-pip libopenblas-base libopenmpi-dev 
pip3 install Cython
pip3 install numpy -i https://pypi.douban.com/simple/
pip3 install torch-1.8.0-cp36-cp36m-linux_aarch64.whl
$ sudo apt-get install libjpeg-dev zlib1g-dev libpython3-dev libavcodec-dev libavformat-dev libswscale-dev
$ git clone --branch v0.9.0 https://gitee.com/momodosky/torchvision.git torchvision
$ cd torchvision
$ export BUILD_VERSION=0.9.0
$ python3 setup.py install --user (如果虚拟机安装,请不要带--user)
$ cd ../
$ pip install 'pillow<7'

要验证您的系统上是否已正确安装PyTorch,请从终端启动交互式Python解释器(python3)并运行以下命令:

>>> import torch
>>> print(torch.__version__)
>>> print('CUDA available: ' + str(torch.cuda.is_available()))

重新打开一个解释器

>>> import torchvision
>>> print(torchvision.__version__)


安装需要的东西

sudo apt-get update
sudo apt-get upgrade
sudo apt install cmake
pip3 install scikit-build

切换python版本

update-alternatives --list python
sudo add-apt-repository ppa:jonathonf/python-3.8
sudo apt-get update
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 2
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 100
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 150
python
pip3 install opencv-python -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com

下载v5
https://github.com/ultralytics/yolov5

解压

$ unzip yolov5-master.zip
$ cd yolov5-master/

更改requirements.txt中
#Pillow
#numpy>=1.18.5
#torch>=1.7.0
#torchvision>=0.8.1
如果有安装不成功,请单独安装,并注释掉,可能与python版本有关。

$ pip3 install -r requirements.txt -i https://pypi.douban.com/simple/

验证

$ python detect.py

关于V4

将darknet放入,并make,按照正常V4流程运行。

安装virtualenv

sudo -H pip3 install virtualenv virtualenvwrapper -i https://pypi.douban.com/simple/

创建虚拟环境目录

mkdir virtualenvs

修改环境变量

vim ~/.bashrc
export WORKON_HOME=(绝对路径)/virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
source /usr/local/bin/virtualenvwrapper.sh

激活

source ~/.bashrc

建置虚拟环境:mkvirtualenv
开启虚拟环境:workon
删除虚拟环境:rmvirtualenv

你可能感兴趣的:(1024程序员节)