本文主要是介绍torch-npu的安装,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
pytorch与CANN的版本有对应关系,请查看网站:
https://gitee.com/ascend/pytorch/tree/v5.0.1.1-pytorch1.11.0
根据自己选定的版本,首先安装pytorch和依赖项:
# for aarch64
pip3 install torch==2.0.1pip3 install pyyaml
pip3 install setuptools
根据对应版本,下载torch-npu安装文件:
https://gitee.com/ascend/pytorch/releases
安装torch-npu:
# 距离,版本自行修改
wget https://gitee.com/ascend/pytorch/releases/download/v5.0.0-pytorch1.11.0/torch_npu-1.11.0.post8-cp38-cp38-linux_aarch64.whlpip3 install torch_npu-1.11.0.post8-cp38-cp38-linux_aarch64.whl
安装完成后,测试发现并不能正常运行:
# 测试代码
import torch
import torch_npux = torch.randn(2, 2).npu()
y = torch.randn(2, 2).npu()
z = x.mm(y)print(z)
会报错:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/ma-user/anaconda3/envs/torch2.0.1/lib/python3.9/site-packages/torch_npu/utils/device_guard.py", line 45, in wrapper
return func(*args, **kwargs)
File "/home/ma-user/anaconda3/envs/torch2.0.1/lib/python3.9/site-packages/torch_npu/utils/tensor_methods.py", line 72, in _npu
return torch_npu._C.npu(self, *args, **kwargs)
RuntimeError: Initialize:/usr1/workspace/FPTA_Daily_v2.0.1_5.0.RC2_py39/CODE/torch_npu/csrc/core/npu/sys_ctrl/npu_sys_ctrl.cpp:199 NPU error, error code is 4294967295.
EC0010: Failed to import Python module [ModuleNotFoundError: No module named 'scipy'.].
Solution: Check that all required components are properly installed and the specified Python path matches the Python installation directory. (If the path does not match the directory, run set_env.sh in the installation package.)
TraceBack (most recent call last):
[GraphOpt][InitializeInner][InitTbeFunc] Failed to init tbe.[FUNC:InitializeInner][FILE:tbe_op_store_adapter.cc][LINE:1641]
[SubGraphOpt][PreCompileOp][InitAdapter] InitializeAdapter adapter [tbe_op_adapter] failed! Ret [4294967295][FUNC:InitializeAdapter][FILE:op_store_adapter_manager.cc][LINE:86]
[SubGraphOpt][PreCompileOp][Init] Initialize op store adapter failed, OpsStoreName[tbe-custom].[FUNC:Initialize][FILE:op_store_adapter_manager.cc][LINE:133]
[FusionMngr][Init] Op store adapter manager init failed.[FUNC:Initialize][FILE:fusion_manager.cc][LINE:109]
PluginManager InvokeAll failed.[FUNC:Initialize][FILE:ops_kernel_manager.cc][LINE:104]
OpsManager initialize failed.[FUNC:InnerInitialize][FILE:gelib.cc][LINE:236]
GELib::InnerInitialize failed.[FUNC:Initialize][FILE:gelib.cc][LINE:164]
需安装其他库:
pip install decorator attrs psutil absl-py cloudpickle scipy synr==0.5.0 tornado
安装完成后,再次测试,发现可行:
这篇关于torch-npu的安装的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!