MANFOLD TX2配置Pytorch1.x方法总结(Python3.5+CUDA9.0+Opencv3.4.1)

硬件环境:

MANFOLD TX2

Ubuntu16.04

Python 3.5

CUDA 9.0

CDUANN 7.x

配置过程

1、查看CUDA与CUDANN版本

dji@manifold2:~$ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2017 NVIDIA Corporation
Built on Sun_Nov_19_03:16:56_CST_2017
Cuda compilation tools, release 9.0, V9.0.252
dji@manifold2:~$ ldconfig -p | grep dnn
        libopencv_dnn.so.3.3 (libc6,AArch64) => /usr/lib/libopencv_dnn.so.3.3
        libopencv_dnn.so (libc6,AArch64) => /usr/lib/libopencv_dnn.so
        libcudnn.so.7 (libc6,AArch64) => /usr/local/cuda-9.0/lib64/libcudnn.so.7
        libcudnn.so.7 (libc6,AArch64) => /usr/lib/aarch64-linux-gnu/libcudnn.so.7
        libcudnn.so (libc6,AArch64) => /usr/lib/aarch64-linux-gnu/libcudnn.so

2、更换TX2国内镜像

 【注意】下载的是ubuntu-ports后缀的镜像源,目前所知中科大的源可用,其他尝试均失败),sudo apt-get install找不到对应的包,无法更新系统软件包和环境依赖。

deb http://mirrors.ustc.edu.cn/ubuntu-ports/  xenial main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu-ports/  xenial-updates main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu-ports/  xenial-security main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/  xenial main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/  xenial-updates main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/  xenial-security main restricted universe multiverse

3、安装环境依赖

sudo apt install libopenblas-dev libatlas-dev liblapack-dev
sudo apt install liblapacke-dev checkinstall
sudo apt-get install python3-pip
pip3 install --upgrade pip
sudo apt-get install python3-dev
sudo pip3 install numpy scipy
sudo pip3 install pyyaml
sudo pip3 install scikit-build
sudo apt-get -y install cmake
sudo apt install libffi-dev
sudo pip3 install cffi

4、添加CUDA和CUDANN路径

sudo gedit ~/.bashrc
#add CUDA path to bashrc
export CUDNN_LIB_DIR=/usr/lib/aarch64-linux-gnu
export CUDNN_INCLUDE_DIR=/usr/include
source ~/.bashrc

5、pip3 安装wheel

感谢torch-1.0.0a0+db5d313-cp35-cp35m-linux_aarch64.whl该github主的无私奉献【开源万岁 *\ ^ ~ ^ /* 】

下载该whl文件,到指定目录下,执行以下命令:

sudo pip3 install torch-1.0.0a0+db5d313-cp35-cp35m-linux_aarch64.whl

两分钟过后你将看到提示:successfully install pytorch

6、测试pytorch是否安装成功

dji@manifold2:~$ python3
Python 3.5.2 (default, Oct  8 2019, 13:06:37)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> print(torch.cuda.is_available())
True

7、配置opencv3.4.1

参见我的另一篇博客: Caffe配置与编译-----OpenCV-3.4.1配置及编译

完成该步骤之后你将看到:

dji@manifold2:~$ pkg-config --modversion opencv
3.4.1
dji@manifold2:~$ python3
Python 3.5.2 (default, Oct  8 2019, 13:06:37)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>>

足够的耐心和恒心,终能找到突破冰川的灿烂千阳!

你可能感兴趣的:(Caffe,Pytorch)