skillfed

torch-npu

NPU bridge for PyTorch

torch-npu v2.12.0 817.2K downloads/30d#4,987 on PyPI
Permissive license BSD License Active released

What it is and what it does

torch-npu is a PyTorch extension that adapts Huawei Ascend NPU hardware to work with PyTorch's standard tensor API. It allows developers to move tensors and operations to Ascend processors using familiar PyTorch syntax (e.g., `.npu()` to move a tensor to NPU), without rewriting core model logic. The package acts as a bridge between PyTorch's compute graph and Ascend's hardware capabilities.

The extension requires PyTorch 2.12.0 and the CANN software stack to be pre-installed on a Linux system (x86_64 or aarch64). Installation is straightforward via pip once dependencies are in place, and the package is actively maintained with recent releases. It targets developers who have access to Ascend hardware and want to leverage it for AI workloads without switching away from PyTorch.

Use it for:

  • Accelerate deep learning training and inference on Ascend NPU hardware without rewriting PyTorch model code.
  • Deploy PyTorch models to Huawei Ascend-based data centers or edge devices for production inference.
  • Evaluate Ascend hardware performance for AI workloads by running existing PyTorch experiments on NPU.
  • Build AI applications targeting Ascend infrastructure in enterprise or cloud environments.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Enables PyTorch to run computations on Huawei Ascend NPU hardware, bridging PyTorch's tensor operations to Ascend AI Processors.

Yes, if you have Ascend NPU hardware or access to an Ascend environment and want to run PyTorch workloads on it. The package is actively maintained, permissively licensed, and integrates cleanly with PyTorch's API. No if you lack Ascend hardware or CANN software—it will not run on CPU or other accelerators. Verify CANN availability and compatibility with your system before installing.

Install

torch-npu on PyPI

pip

pip install torch-npu

uv

uv add torch-npu

poetry

poetry add torch-npu

Installing torch-npu

Before you install

Medium friction: requires torch 2.12.0 as a runtime dependency and CANN (Ascend Auxiliary Software) pre-installed on the system. Wheels are available for Python 3.10–3.13 on x86_64 and aarch64 Linux. Active maintenance with a release 18 days old.

License in practice

BSD License (permissive) allows commercial and private use with minimal restrictions; attribution required.

Quickstart

# Install PyTorch 2.12.0 first, then torch-npu
pip install torch==2.12.0 --index-url https://download.pytorch.org/whl/cpu
pip install torch-npu==2.12.0rc1

# Use Ascend NPU for tensor operations
import torch
x = torch.randn(2, 2).npu()
y = torch.randn(2, 2).npu()
z = x.mm(y)
print(z)

Requires CANN (Ascend Auxiliary Software) to be installed and initialized via source /usr/local/Ascend/ascend-toolkit/set_env.sh; Ascend NPU hardware or emulation environment must be available.

Verify before relying

  • Whether CANN installation is straightforward or requires specialized knowledge for most developers.
  • Performance characteristics and typical speedup factors compared to CPU PyTorch on Ascend hardware.
  • Compatibility of existing PyTorch models and whether code changes beyond .npu() calls are typically needed.

Package facts

License BSD License (permissive)
Python support not specified
Install friction medium — platform-specific wheel
Runtime dependencies 1 — torch
Maintenance actively maintained — 18 days since the last release
First released
Downloads 817,171/month — #4,987 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: torch_npu-2.12.0-cp310-cp310-manylinux_2_28_aarch64.whl; torch_npu-2.12.0-cp310-cp310-manylinux_2_28_x86_64.whl; torch_npu-2.12.0-cp311-cp311-manylinux_2_28_aarch64.whl; torch_npu-2.12.0-cp311-cp311-manylinux_2_28_x86_64.whl; torch_npu-2.12.0-cp312-cp312-manylinux_2_28_aarch64.whl; torch_npu-2.12.0-cp312-cp312-manylinux_2_28_x86_64.whl; torch_npu-2.12.0-cp313-cp313-manylinux_2_28_aarch64.whl; torch_npu-2.12.0-cp313-cp313-manylinux_2_28_x86_64.whl

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseOperating System :: POSIX :: LinuxProgramming Language :: PythonProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Scientific/EngineeringTopic :: Scientific/Engineering :: Artificial IntelligenceTopic :: Scientific/Engineering :: MathematicsTopic :: Software DevelopmentTopic :: Software Development :: LibrariesTopic :: Software Development :: Libraries :: Python Modules

Tags

pytorch ascend npu accelerationhuawei npu pytorch backendascend processor pytorch supportnpu tensor computation pytorchpytorch hardware acceleration ascendascend ai processor pytorchnpu device pytorch bridge
hardware-accelerationascend-npupytorch-extension

More Software Development packages