ubuntu16.04自带的g++,gcc为5.4,因此另外安装4.9
sudo apt install gcc-4.9 g++-4.9
export CC="gcc-4.9"
export CXX="g++-4.9"
激活anaconda
cd /home/aistudio/miniconda3/bin
source ./activate torch_build
设置cmake选项
export CMAKE_PREFIX_PATH=/home/aistudio/miniconda3/envs/torch_build
禁用nvcc
export USE_NVCC=0
编译
cd /home/aistudio/torch_build/pytorch-1.2.0
python setup.py clean
python setup.py install