安装依赖
conda install astunparse numpy ninja pyyaml mkl mkl-include setuptools cmake cffi typing_extensions future six requests dataclasses
# CUDA only: Add LAPACK support for the GPU if needed
conda install -c pytorch magma-cuda110 # or the magma-cuda* that matches your CUDA version from https://anaconda.org/pytorch/repo
获取源码
git clone --recursive https://github.com/pytorch/pytorch
cd pytorch
git checkout v1.8.1
# if you are updating an existing checkout
git submodule sync
git submodule update --init --recursive
安装
export CMAKE_PREFIX_PATH=${CONDA_PREFIX:-"$(dirname $(which conda))/../"}
DEBUG=1 python setup.py develop
Error
找不到cudnn版本
-- Caffe2: CUDA detected: 11.2 │······································
-- Caffe2: CUDA nvcc is: /usr/local/cuda/bin/nvcc │······································
-- Caffe2: CUDA toolkit directory: /usr/local/cuda │······································
-- Caffe2: Header version is: 11.2 │······································
-- Found cuDNN: v? (include: /usr/local/cuda/include, library: /usr/local/cuda/lib64/libcudnn.so) │······································
CMake Error at cmake/public/cuda.cmake:174 (message): │······································
PyTorch requires cuDNN 7 and above. │······································
Call Stack (most recent call first): │······································
cmake/Dependencies.cmake:1151 (include) │······································
CMakeLists.txt:623 (include)
- 首先查看CUDNN的版本
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
No space left on device
https://stackoverflow.com/questions/44270171/torch-installation-failure-no-space-left-on-device
mkdir $HOME/tmp
export TMPDIR=$HOME/tmp