目录
升级gcc g++ cmake
安装依赖包
下载pytorch
切换工作模式
?开始编译,不能使用sudo
编译错误整理:
升级gcc g++ cmake
使用gcc -v 和 g++ -v 查看版本,原环境的gcc和g++版本为7,最好升级到8
sudo apt-get update
sudo apt-get install gcc-8
sudo apt-get install g++-8
//添加update-alternatives进行版本管理
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 10
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 10
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 10
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 10
//版本管理,如下图所示,切换到gcc-8,g++-8
sudo update-alternatives --config gcc
sudo update-alternatives --config g++
//切换完成后再次查看版本
?
wget https://cmake.org/files/v3.22/cmake-3.22.1.tar.gz
tar -xvzf cmake-3.22.1.tar.gz
cd cmake-3.22.1/
chmod 777 ./configure
./configure
make -j8
sudo make install
sudo update-alternatives --install /usr/bin/cmake cmake /usr/local/bin/cmake 1 --force
cmake --version
安装依赖包
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
下载pytorch
下载submodule需要注意,不能手动下载,使用git submodule update 会自动切换到指定版本,此处未弄明白为什么会自动切换。此处很关键,文件下载正确后后边编译基本没有什么错误,之前手动下的包,差点坑吐血。
git clone http://github.com/pytorch/pytorch
cd pytorch
sudo pip3 install -U setuptools
sudo pip3 install -r requirements.txt
git submodule update --init --recursive
切换工作模式
sudo nvpmodel -m 0 # 切换工作模式到最大
sudo ~/jetson_clocks.sh # 强制开启风扇最大转速
export USE_NCCL=0
export USE_DISTRIBUTED=0
export TORCH_CUDA_ARCH_LIST="5.3;6.2;7.2"
?开始编译,不能使用sudo
mkdir build
cd build
python3 ../tools/build_libtorch.py
编译错误整理:
In file included from ./include/caffe/parallel.hpp:19:0,
from ./include/caffe/caffe.hpp:13,
from tools/caffe.cpp:15:
./include/caffe/util/nccl.hpp:5:18: fatal error: nccl.h: No such file or directory
compilation terminated.
Makefile:591: recipe for target '.build_release/tools/caffe.o' failed
make: *** [.build_release/tools/caffe.o] Error 1
make: *** Waiting for unfinished jobs....
解决办法:
cd third_part/nccl/nccl
sudo make install -j4
sudo ldconfig
- Error: operand mismatch -- `mov V8.4s,V9.4s'
修改/home/hw/Tools/pytorch/aten/src/ATen/native/quantized/cpu/qnnpack/src/q8gemm/8x8-dq-aarch64-neon.S
- MOV V8.4s, V9.4s
- MOV v10.4s, v11.4s
- MOV v12.4s, V13.4s
- MOV V14.4s, V15.4s
- MOV V16.4s, V17.4s
- MOV V18.4s, V19.4s
- MOV V20.4s, V21.4s
- MOV V22.4s, V23.4s
+ MOV V8.16b, V9.16b
+ MOV v10.16b, v11.16b
+ MOV v12.16b, V13.16b
+ MOV V14.16b, V15.16b
+ MOV V16.16b, V17.16b
+ MOV V18.16b, V19.16b
+ MOV V20.16b, V21.16b
+ MOV V22.16b, V23.16b
编译结果
?
将torch文件夹中的bin,include,lib,share,build-hash,build-version整理打包
|