TX2配置yolov5环境
TX2系统版本:
lsb_release -a
No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 18.04.6 LTS Release: 18.04 Codename: bionic
更新系统和包:
sudo apt-get update sudo apt-get upgrade
安装Archiconda3
下载好使用ftp或者其他工具拖进去 cd进入目录运行下面命令
bash Archiconda3-0.2.3-Linux-aarch64.sh
根据提示输入yes或者enter 会自动添加路径,如果最后没有按yes需要手动添加archiconda的安装路径到bashrc
测试:source archiconda3/bin/activate
退出:source deactivate
可能会存在每次打开都是默认进入base环境,需要在bashrc里面添加一条语句:
source deactivate
创建运行yolov5的虚拟环境
conda create -n yolov5_py36 python=3.6 #创建一个python3.6环境
conda info --envs # 查看所有环境
conda activate yolov5_py36 #进入环境
conda deactivate # 退出环境
换源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
安装一些包和库
sudo apt-get dist-upgrade sudo apt-get install python3-pip libopenblas-base libopenmpi-dev
进入我们的yolov5运行环境
conda activate yolov5_py36 pip3 install --upgrade pip #如果pip已是最新,可不执行 上述命令会报错可用下面的命令换源更新:
pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade pip
安装pytorch和torchvison(最重要的地方)
查看JetPack版本:
sudo apt-cache show nvidia-jetpack
1)安装pytorch不仅需要查看python版本也需要查看JetPack版本
2)因为python3.8需要安装的Pytorch都是在JetPack5上安装的,而jetson TX2的
JetPack是4.6.4-b39,所以配置yolov5的环境需要使用python3.6,整体的环境是
JetPack4.6.4-b39---Python3.6---PyTorch1.8(torch1.8_aarch64),
PyTorch可选版本在1.10-1.0之间,如果是JetPack5以上,那么可选的PyTorch在1.11-2.1之间。
版本对应连接,下载地址:PyTorch for Jetson - Jetson & Embedded Systems / Jetson Nano - NVIDIA Developer Forums
下载PyTorch1.8(torch1.8_aarch64)
网址下载:上述网址下载,我下载失败了 网盘下载:
链接:https://pan.baidu.com/s/1a-8Rdg-6_r6eHn3nveKOBg?pwd=hkhx 提取码:hkhx
安装
安装pytorch 进入我们的yolov5运行环境
conda activate yolov5_py36
然后找到下载好的torch-1.8.0-cp36-cp36m-linux_aarch64.whl包的所在文件夹,
进入文件夹中,输入安装命令:
pip3 install torch-1.8.0-cp36-cp36m-linux_aarch64.whl #注意安装包的位置
测试报错:
(yolov5_py36) an@TX2:~$ python Python 3.6.15 | packaged by conda-forge | (default, Dec 3 2021, 19:12:04) [GCC 9.4.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import torch Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/an/archiconda3/envs/yolov5_py36/lib/python3.6/site-packages/torch/__init__.py", line 195, in <module> _load_global_deps() File "/home/an/archiconda3/envs/yolov5_py36/lib/python3.6/site-packages/torch/__init__.py", line 148, in _load_global_deps ctypes.CDLL(lib_path, mode=ctypes.RTLD_GLOBAL) File "/home/an/archiconda3/envs/yolov5_py36/lib/python3.6/ctypes/__init__.py", line 348, in __init__ self._handle = _dlopen(self._name, mode) OSError: libcurand.so.10: cannot open shared object file: No such file or directory >>> [3]+ Stopped python
报错原因:
ls /path/to/libcurand.so.10
结果显示文件不存在所以是没有安装 可能需要安装或重新安装CUDA Toolkit和cuDNN库,这是Torch所需的
安装cuda
/usr/local/cuda/version.txt
显示没安装cuda
【精选】jetson tx2 安装cuda 10.2或者cuda 9全过程_tx2安装cuda_wangxinRS的博客-CSDN博客
里面安装文件移动cuda10.2权限不够,需要线移到其他文件,然后cd到目标文件下 :
sudo mv 目标文件 /usr/local/
测试报错:
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/an/archiconda3/envs/yolov5_py36/lib/python3.6/site-packages/torch/__init__.py", line 195, in <module> _load_global_deps() File "/home/an/archiconda3/envs/yolov5_py36/lib/python3.6/site-packages/torch/__init__.py", line 148, in _load_global_deps ctypes.CDLL(lib_path, mode=ctypes.RTLD_GLOBAL) File "/home/an/archiconda3/envs/yolov5_py36/lib/python3.6/ctypes/__init__.py", line 348, in __init__ self._handle = _dlopen(self._name, mode) OSError: libcudnn.so.8: cannot open shared object file: No such file or directory
安装cudnn
Jetson系列Ubuntu--CUDA、cudnn快速安装(Jetson Xavier NX上实践可行)_xavie nx的cudnn安装在什么位置_a111222zw的博客-CSDN博客
报错解决
安装torchvision
进入trochvision文件夹中, 执行命令:
export BUILD_VERSION=0.9.0
然后执行安装命令:
python setup.py install
等待等待,需要比较长时间
install报错:
During handling of the above exception, another exception occurred: Traceback (most recent call last):File "setup.py", line 475, in <module>'clean': clean,File "/home/an/archiconda3/envs/yolov5_py36/lib/python3.6/site-packages/setuptools/init.py", line 153, in setupreturn distutils.core.setup(**attrs)File "/home/an/archiconda3/envs/yolov5_py36/lib/python3.6/distutils/core.py", line 148, in setupdist.run_commands()File "/home/an/archiconda3/envs/yolov5_py36/lib/python3.6/distutils/dist.py", line 955, in run_commandsself.run_command(cmd)File "/home/an/archiconda3/envs/yolov5_py36/lib/python3.6/distutils/dist.py", line 974, in run_commandcmd_obj.run()File "/home/an/archiconda3/envs/yolov5_py36/lib/python3.6/site-packages/setuptools/command/install.py", line 67, in runself.do_egg_install()File "/home/an/archiconda3/envs/yolov5_py36/lib/python3.6/site-packages/setuptools/command/install.py", line 117, in do_egg_installcmd.run(show_deprecation=False)File "/home/an/archiconda3/envs/yolov5_py36/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 408, in runself.easy_install(spec, not self.no_deps)File "/home/an/archiconda3/envs/yolov5_py36/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 650, in easy_installreturn self.install_item(None, spec, tmpdir, deps, True)File "/home/an/archiconda3/envs/yolov5_py36/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 697, in install_itemself.process_distribution(spec, dist, deps)File "/home/an/archiconda3/envs/yolov5_py36/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 745, in process_distribution[requirement], self.local_index, self.easy_installFile "/home/an/archiconda3/envs/yolov5_py36/lib/python3.6/site-packages/pkg_resources/init.py", line 768, in resolvereplace_conflicting=replace_conflictingFile "/home/an/archiconda3/envs/yolov5_py36/lib/python3.6/site-packages/pkg_resources/init.py", line 1051, in best_matchreturn self.obtain(req, installer)File "/home/an/archiconda3/envs/yolov5_py36/lib/python3.6/site-packages/pkg_resources/init.py", line 1063, in obtainreturn installer(requirement)File "/home/an/archiconda3/envs/yolov5_py36/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 669, in easy_installreturn self.install_item(spec, dist.location, tmpdir, deps)File "/home/an/archiconda3/envs/yolov5_py36/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 695, in install_itemdists = self.install_eggs(spec, download, tmpdir)File "/home/an/archiconda3/envs/yolov5_py36/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 890, in install_eggsreturn self.build_and_install(setup_script, setup_base)File "/home/an/archiconda3/envs/yolov5_py36/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 1162, in build_and_installself.run_setup(setup_script, setup_base, args)File "/home/an/archiconda3/envs/yolov5_py36/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 1146, in run_setuprun_setup(setup_script, args)File "/home/an/archiconda3/envs/yolov5_py36/lib/python3.6/site-packages/setuptools/sandbox.py", line 262, in run_setupraiseFile "/home/an/archiconda3/envs/yolov5_py36/lib/python3.6/contextlib.py", line 99, in exitself.gen.throw(type, value, traceback)File "/home/an/archiconda3/envs/yolov5_py36/lib/python3.6/site-packages/setuptools/sandbox.py", line 198, in setup_contextyieldFile "/home/an/archiconda3/envs/yolov5_py36/lib/python3.6/contextlib.py", line 99, in exitself.gen.throw(type, value, traceback)File "/home/an/archiconda3/envs/yolov5_py36/lib/python3.6/site-packages/setuptools/sandbox.py", line 169, in save_modulessaved_exc.resume()File "/home/an/archiconda3/envs/yolov5_py36/lib/python3.6/site-packages/setuptools/sandbox.py", line 143, in resumeraise exc.with_traceback(self._tb)File "/home/an/archiconda3/envs/yolov5_py36/lib/python3.6/site-packages/setuptools/sandbox.py", line 156, in save_modulesyield savedFile "/home/an/archiconda3/envs/yolov5_py36/lib/python3.6/site-packages/setuptools/sandbox.py", line 198, in setup_contextyieldFile "/home/an/archiconda3/envs/yolov5_py36/lib/python3.6/site-packages/setuptools/sandbox.py", line 259, in run_setup_execfile(setup_script, ns)File "/home/an/archiconda3/envs/yolov5_py36/lib/python3.6/site-packages/setuptools/sandbox.py", line 46, in _execfileexec(code, globals, locals)File "/tmp/easy_install-dvrr7ega/Pillow-10.1.0/setup.py", line 1005, in <module>setuptools.sandbox.UnpickleableException: RequiredDependencyException('\n\nThe headers or library files could not be found for jpeg,\na required dependency when compiling Pillow from source.\n\nPlease see the install instructions at:\n https://pillow.readthedocs.io/en/latest/installation.html\n\n',)(yolov5_py36) an@TX2:~/torchvision$
Installed /home/an/archiconda3/envs/yolov5_py36/lib/python3.6/site-packages/torchvision-0.9.0a0+01dfa8e-py3.6-linux-aarch64.egg Processing dependencies for torchvision==0.9.0a0+01dfa8e Searching for pillow>=4.1.1 Reading https://pypi.org/simple/pillow/ error: The read operation timed out?
解决办法:
pip --default-timeout=100 install pillow -i https://pypi.tuna.tsinghua.edu.cn/simple
成功测试:
cd退出目录
python
import torchvision
print(torchvision.__version__)
0.9.0
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。 如若内容造成侵权/违法违规/事实不符,请联系我的编程经验分享网邮箱:veading@qq.com进行投诉反馈,一经查实,立即删除!