安装环境:
华为泰山服务器 aarch64构架
Python环境
Miniforge3 aarch64版本 (https://github.com/conda-forge/miniforge/releases)
安装步骤
- 安装conda依赖
conda install numpy ninja pyyaml setuptools cmake cffi typing_extensions future six requests dataclasses
- 下载资源
git clone --recursive https://github.com.cnpmjs.org/pytorch/pytorch
cd pytorch
# if you are updating an existing checkout
git submodule sync
git submodule update --init --recursive
- 配置环境变量
export NO_CUDA=1
export NO_DISTRIBUTED=1
export NO_MKLDNN=1
export BUILD_TEST=0
export MAX_JOBS=96
- 编译
export CMAKE_PREFIX_PATH=${CONDA_PREFIX:-"$(dirname $(which conda))/../"}
python setup.py install --user
- 测试
import torch
此时可能会出现异常
ImportError: Failed to load PyTorch C extensions:
It appears that PyTorch has loaded the `torch/_C` folder
of the PyTorch repository rather than the C extensions which
are expected in the `torch._C` namespace. This can occur when
using the `install` workflow. e.g.
$ python setup.py install && python -c "import torch"
This error can generally be solved using the `develop` workflow
$ python setup.py develop && python -c "import torch" # This should succeed
or by running Python from a different directory.
按照提示运行以下命令
python setup.py develop --user
- 安装完成!