安装依赖

先安装anaconda,再创建虚拟环境。手动激活conda

eval "$(/home/find/anaconda3/bin/conda shell.bash hook)"
conda create -n pytorch python=3.7
conda activate pytorch

使用python3.7是因为后续安装的pytorch/benchmark建议使用3.7版本,可以忽略该建议。如果你的虚拟环境需要一个不同的python,不要直接在base环境中install python=3.7,否则会有一个很久且很难成功的python版本兼容性检查。

conda install astunparse numpy ninja pyyaml mkl mkl-include setuptools cmake cffi typing_extensions future six requests dataclasses
conda install -c pytorch magma-cuda112

可以在 https://anaconda.org/search?q=magma 找到可用的magma版本。

下载编译pytorch

git clone --recursive https://github.com/pytorch/pytorch
cd pytorch
# if you are updating an existing checkout
git submodule sync
git submodule update --init --recursive --jobs 0
export CMAKE_PREFIX_PATH=${CONDA_PREFIX:-"$(dirname $(which conda))/../"}
export USE_CUDA=1
export REL_WITH_DEB_INFO=1
export MAX_JOBS=16
export USE_NINJA=OFF 
python setup.py install

通过conda list | grep torch可以查看安装结果。

下载编译pytorch/benchmark

根据该repo github的介绍,安装benchmark之前还需要先手动编译安装torchtext和torchvision。步骤都比较简单。

torchtext

export FORCE_CUDA=1
git clone https://github.com/pytorch/text torchtext
cd torchtext
git submodule update --init --recursive

# Linux
python setup.py clean install

torch vision

git clone [email protected]:pytorch/vision.git
python setup.py install

benchmark

git clone [email protected]:pytorch/benchmark.git
cd benchmark
python install.py

文章版权归 FindHao 所有丨本站默认采用CC-BY-NC-SA 4.0协议进行授权|
转载必须包含本声明,并以超链接形式注明作者 FindHao 和本文原始地址:
https://findhao.net/academic/2590.html

Comments