安装torch_npu插件

torch_npu插件有如下两种安装方式:

获取安装命令

执行安装命令前,请参见安装前必读完成环境变量配置。

表1 安装torch_npu插件

PyTorch版本

torch_npu插件版本

Python版本

系统架构

CANN版本

安装方式

安装命令

2.1.0

6.0.0

Python 3.8

AArch64

8.0.0

Pip

# 下载插件包
wget https://gitee.com/ascend/pytorch/releases/download/v6.0.0-pytorch2.1.0/torch_npu-2.1.0.post10-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
# 安装命令
pip3 install torch_npu-2.1.0.post10-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Source

# 参见下方“源码编译安装torch_npu插件”

6.0.0

Python 3.8

X86_64

8.0.0

Pip

# 下载插件包
wget https://gitee.com/ascend/pytorch/releases/download/v6.0.0-pytorch2.1.0/torch_npu-2.1.0.post10-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
# 安装命令
pip3 install torch_npu-2.1.0.post10-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Source

# 参见下方“源码编译安装torch_npu插件”

6.0.0

Python 3.9

AArch64

8.0.0

Pip

# 下载插件包
wget https://gitee.com/ascend/pytorch/releases/download/v6.0.0-pytorch2.1.0/torch_npu-2.1.0.post10-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
# 安装命令
pip3 install torch_npu-2.1.0.post10-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Source

# 参见下方“源码编译安装torch_npu插件”

6.0.0

Python 3.9

X86_64

8.0.0

Pip

# 下载插件包
wget https://gitee.com/ascend/pytorch/releases/download/v6.0.0-pytorch2.1.0/torch_npu-2.1.0.post10-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
# 安装命令
pip3 install torch_npu-2.1.0.post10-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Source

# 参见下方“源码编译安装torch_npu插件”

6.0.0

Python 3.10

AArch64

8.0.0

Pip

# 下载插件包
wget https://gitee.com/ascend/pytorch/releases/download/v6.0.0-pytorch2.1.0/torch_npu-2.1.0.post10-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
# 安装命令
pip3 install torch_npu-2.1.0.post10-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Source

# 参见下方“源码编译安装torch_npu插件”

6.0.0

Python 3.10

X86_64

8.0.0

Pip

# 下载插件包
wget https://gitee.com/ascend/pytorch/releases/download/v6.0.0-pytorch2.1.0/torch_npu-2.1.0.post10-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
# 安装命令
pip3 install torch_npu-2.1.0.post10-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Source

# 参见下方“源码编译安装torch_npu插件”

6.0.0

Python 3.11

AArch64

8.0.0

Pip

# 下载插件包
wget https://gitee.com/ascend/pytorch/releases/download/v6.0.0-pytorch2.1.0/torch_npu-2.1.0.post10-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
# 安装命令
pip3 install torch_npu-2.1.0.post10-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Source

# 参见下方“源码编译安装torch_npu插件”

6.0.0

Python 3.11

X86_64

8.0.0

Pip

# 下载插件包
wget https://gitee.com/ascend/pytorch/releases/download/v6.0.0-pytorch2.1.0/torch_npu-2.1.0.post10-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
# 安装命令
pip3 install torch_npu-2.1.0.post10-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Source

# 参见下方“源码编译安装torch_npu插件”

2.3.1

6.0.0

Python 3.8

AArch64

8.0.0

Pip

# 下载插件包
wget https://gitee.com/ascend/pytorch/releases/download/v6.0.0-pytorch2.3.1/torch_npu-2.3.1.post4-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
# 安装命令
pip3 install torch_npu-2.3.1.post4-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Source

# 参见下方“源码编译安装torch_npu插件”

6.0.0

Python 3.8

X86_64

8.0.0

Pip

# 下载插件包
wget https://gitee.com/ascend/pytorch/releases/download/v6.0.0-pytorch2.3.1/torch_npu-2.3.1.post4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
# 安装命令
pip3 install torch_npu-2.3.1.post4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Source

# 参见下方“源码编译安装torch_npu插件”

6.0.0

Python 3.9

AArch64

8.0.0

Pip

# 下载插件包
wget https://gitee.com/ascend/pytorch/releases/download/v6.0.0-pytorch2.3.1/torch_npu-2.3.1.post4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
# 安装命令
pip3 install torch_npu-2.3.1.post4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Source

# 参见下方“源码编译安装torch_npu插件”

6.0.0

Python 3.9

X86_64

8.0.0

Pip

# 下载插件包
wget https://gitee.com/ascend/pytorch/releases/download/v6.0.0-pytorch2.3.1/torch_npu-2.3.1.post4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
# 安装命令
pip3 install torch_npu-2.3.1.post4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Source

# 参见下方“源码编译安装torch_npu插件”

6.0.0

Python 3.10

AArch64

8.0.0

Pip

# 下载插件包
wget https://gitee.com/ascend/pytorch/releases/download/v6.0.0-pytorch2.3.1/torch_npu-2.3.1.post4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
# 安装命令
pip3 install torch_npu-2.3.1.post4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Source

# 参见下方“源码编译安装torch_npu插件”

6.0.0

Python 3.10

X86_64

8.0.0

Pip

# 下载插件包
wget https://gitee.com/ascend/pytorch/releases/download/v6.0.0-pytorch2.3.1/torch_npu-2.3.1.post4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
# 安装命令
pip3 install torch_npu-2.3.1.post4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Source

# 参见下方“源码编译安装torch_npu插件”

6.0.0

Python 3.11

AArch64

8.0.0

Pip

# 下载插件包
wget https://gitee.com/ascend/pytorch/releases/download/v6.0.0-pytorch2.3.1/torch_npu-2.3.1.post4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
# 安装命令
pip3 install torch_npu-2.3.1.post4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Source

# 参见下方“源码编译安装torch_npu插件”

6.0.0

Python 3.11

X86_64

8.0.0

Pip

# 下载插件包
wget https://gitee.com/ascend/pytorch/releases/download/v6.0.0-pytorch2.3.1/torch_npu-2.3.1.post4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
# 安装命令
pip3 install torch_npu-2.3.1.post4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Source

# 参见下方“源码编译安装torch_npu插件”

2.4.0

6.0.0

Python 3.8

AArch64

8.0.0

Pip

# 下载插件包
wget https://gitee.com/ascend/pytorch/releases/download/v6.0.0-pytorch2.4.0/torch_npu-2.4.0.post2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
# 安装命令
pip3 install torch_npu-2.4.0.post2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Source

# 参见下方“源码编译安装torch_npu插件”

6.0.0

Python 3.8

X86_64

8.0.0

Pip

# 下载插件包
wget https://gitee.com/ascend/pytorch/releases/download/v6.0.0-pytorch2.4.0/torch_npu-2.4.0.post2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
# 安装命令
pip3 install torch_npu-2.4.0.post2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Source

# 参见下方“源码编译安装torch_npu插件”

6.0.0

Python 3.9

AArch64

8.0.0

Pip

# 下载插件包
wget https://gitee.com/ascend/pytorch/releases/download/v6.0.0-pytorch2.4.0/torch_npu-2.4.0.post2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
# 安装命令
pip3 install torch_npu-2.4.0.post2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Source

# 参见下方“源码编译安装torch_npu插件”

6.0.0

Python 3.9

X86_64

8.0.0

Pip

# 下载插件包
wget https://gitee.com/ascend/pytorch/releases/download/v6.0.0-pytorch2.4.0/torch_npu-2.4.0.post2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
# 安装命令
pip3 install torch_npu-2.4.0.post2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Source

# 参见下方“源码编译安装torch_npu插件”

6.0.0

Python 3.10

AArch64

8.0.0

Pip

# 下载插件包
wget https://gitee.com/ascend/pytorch/releases/download/v6.0.0-pytorch2.4.0/torch_npu-2.4.0.post2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
# 安装命令
pip3 install torch_npu-2.4.0.post2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Source

# 参见下方“源码编译安装torch_npu插件”

6.0.0

Python 3.10

X86_64

8.0.0

Pip

# 下载插件包
wget https://gitee.com/ascend/pytorch/releases/download/v6.0.0-pytorch2.4.0/torch_npu-2.4.0.post2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
# 安装命令
pip3 install torch_npu-2.4.0.post2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Source

# 参见下方“源码编译安装torch_npu插件”

6.0.0

Python 3.11

AArch64

8.0.0

Pip

# 下载插件包
wget https://gitee.com/ascend/pytorch/releases/download/v6.0.0-pytorch2.4.0/torch_npu-2.4.0.post2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
# 安装命令
pip3 install torch_npu-2.4.0.post2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Source

# 参见下方“源码编译安装torch_npu插件”

6.0.0

Python 3.11

X86_64

8.0.0

Pip

# 下载插件包
wget https://gitee.com/ascend/pytorch/releases/download/v6.0.0-pytorch2.4.0/torch_npu-2.4.0.post2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
# 安装命令
pip3 install torch_npu-2.4.0.post2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Source

# 参见下方“源码编译安装torch_npu插件”

更多PyTorch插件版本可单击Link查询。

  • 执行如下命令,若返回True则说明安装成功。
    python3 -c "import torch;import torch_npu;print(torch_npu.npu.is_available())"
  • 若PyTorch版本为2.1.0,出现“找不到google或者protobuf或者protobuf版本过高”报错时,需执行如下命令:
    pip3 install protobuf==3.20

源码编译安装torch_npu插件

以下操作步骤以安装PyTorch 2.1.0版本为例。

验证是否成功安装