在AGX刷机之后,马上开始安装pytorch、opencv、mmdetection等深度学习常用的工具。记录一下安装的过程和踩的坑,有些坑还没填上。
pip源设置
sudo apt-get install python3-pip
mkdir ~/.pip
vim ~/.pip/pip.conf
在pip.conf里写入清华源
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
pytorch
直接pip3 install是不行的,清华源里没有torch的aarch64的预编译版本。得去Jeston Zoo官网找相关的版本。
网址(需要梯子):https://elinux.org/Jetson_Zoo#PyTorch_.28Caffe2.29
无梯子,进百度云盘:https://pan.baidu.com/s/1lLK4C-TtZE3xhXUIcNk0XQ 密码: 0o82
torch1.4, torch1.5,torch1.6都试过,其中torch1.5的安装没有成功 T_T 这个坑留给大家填
参考https://blog.csdn.net/u013595260/article/details/107180928/
# torch:
# install OpenBLAS and OpenMPI
$ sudo apt-get install libopenblas-base libopenmpi-dev
# Python 3.6 (download pip wheel from above)
pip3 install Cython
pip3 install numpy torch-1.4.0-cp36-cp36m-linux_aarch64.whl
torchvision
没有torchvision的aarch64的预编译版本,只能源码编译,这里是torchvision0.5.0
编译过程中,如果卡在Running setup.py bdist_wheel for …等环节止步不前,这时系统正在编译,过程很漫长,可以喝杯咖啡打会儿游戏。
git clone -b v0.5.0 https://github.com/pytorch/vision
cd vision
sudo python3 setup.py install
pillow
sudo apt-get install libtiff5-dev libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev libharfbuzz-dev libfribidi-dev tcl8.6-dev tk8.6-dev python3-tk
pip3 install pillow
mmcv-full & mmdetection
编译mmcv-full也是一个漫长的过程,卡在Running setup.py … 或者Building wheel for …很久,静静等待。
mmdetection安装成功后,在运行demo.py的时候没什么问题,运行结束的时候报出 Segmentation fault (core dumped)问题。这也是个坑
分别试过torch1.4和torch1.6,全都报错:
1)mmdetection with torch1.4: Segmentation fault (core dumped))
2)mmdetection with torch1.6: ImportError: /home/sh/.local/lib/python3.6/site-packages/mmcv/_ext.cpython-36m-aarch64-linux-gnu.so: undefined symbol: _ZTIN3c1021AutogradMetaInterfaceE
pip3 install mmcv-full
git clone https://github.com/open-mmlab/mmdetection.git
cd mmdetection
pip3 install -r requirements/build.txt
pip3 install -v -e .
opencv4.4 cuda版编译
百度云盘:https://pan.baidu.com/s/1lLK4C-TtZE3xhXUIcNk0XQ 密码: 0o82
opencv的扩展模块及编译需要的各种*.i文件都在云盘里了
值得注意的是,cmake命令中CUDA_ARCH_BIN大小要根据自己的设备来定
参考https://blog.csdn.net/CSS360/article/details/109696878
mkdir build
cd buid
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local/opencv4 -D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib-4.4.0/modules -D WITH_CUDA=1 -D WITH_CUDNN=1 -D OPENCV_DNN_CUDA=1 -D ENABLE_FAST_MATH=1 -D CUDA_FAST_MATH=1 -D ENABLE_FAST_MATH=1 -D WITH_CUBLAS=1 -D HAVE_opencv_python3=1 -D OPENCV_GENERATE_PKGCONFIG=1 -D CUDA_ARCH_BIN=7.2 ..
sudo make -j8
sudo make install
编译依旧漫长…