请完成PyTorch 1.5.0框架的安装。
git clone https://github.com/HDFGroup/hdf5.git
cd hdf5 git checkout hdf5-1_10_7
./configure --prefix=/usr/local/hdf5 --enable-cxx make -j72 #-j 后的数值可以根据CPU的核数设置 make check # run test suite. make install make check-install # verify installation.
export PATH=/usr/local/hdf5/bin:$PATH export LD_LIBRARY_PATH=/usr/local/hdf5/lib:$LD_LIBRARY_PATH export LIBRARY_PATH=/usr/local/hdf5/lib:$LIBRARY_PATH export CPATH=/usr/local/hdf5/include:$CPATH
cd pytorch vim build.sh
当需要获取基于昇腾AI处理器执行模型训练生成的数据文件时,须将build.sh文件中的“DEBUG=0 USE_DISTRIBUTED=1 USE_HCCL=1 USE_MKLDNN=0 USE_CUDA=0 USE_NPU=1 BUILD_TEST=0 USE_NNPACK=0 python3 setup.py build bdist_wheel”中添加“USE_DUMP=1”字段。修改示例如下:
DEBUG=0 USE_DISTRIBUTED=1 USE_HCCL=1 USE_MKLDNN=0 USE_CUDA=0 USE_NPU=1 BUILD_TEST=0 USE_NNPACK=0 python3 setup.py build bdist_wheel
DEBUG=0 USE_DISTRIBUTED=1 USE_HCCL=1 USE_MKLDNN=0 USE_CUDA=0 USE_NPU=1 BUILD_TEST=0 USE_NNPACK=0 USE_DUMP=1 python3 setup.py build bdist_wheel
GPU版本需要在GPU服务器上安装CUDA中的CUDNN库后编译。
修改示例如下:
# for build GPU torch:DEBUG=0 USE_DISTRIBUTED=0 USE_HCCL=0 USE_NCCL=0 USE_MKLDNN=0 USE_CUDA=1 USE_NPU=0 BUILD_TEST=0 USE_NNPACK=0 python3.7 setup.py build bdist_wheel DEBUG=0 USE_DISTRIBUTED=1 USE_HCCL=1 USE_MKLDNN=0 USE_CUDA=0 USE_NPU=1 BUILD_TEST=0 USE_NNPACK=0 python3 setup.py build bdist_wheel
DEBUG=0 USE_DISTRIBUTED=0 USE_HCCL=0 USE_NCCL=0 USE_MKLDNN=0 USE_CUDA=1 USE_NPU=0 BUILD_TEST=0 USE_NNPACK=0 USE_DUMP=1 python3.7 setup.py build bdist_wheel # DEBUG=0 USE_DISTRIBUTED=1 USE_HCCL=1 USE_MKLDNN=0 USE_CUDA=0 USE_NPU=1 BUILD_TEST=0 USE_NNPACK=0 python3 setup.py build bdist_wheel
bash build.sh
pip3 uninstall torch pip3 install torch-1.5.0+ascend.post2-cp37-cp37m-linux_x86_64.whl
python3 import torch
若执行import torch命令不提示错误,则Python环境安装成功。