torch-npu
NPU bridge for PyTorch
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-npuuv
uv add torch-npupoetry
poetry add torch-npuInstalling 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
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
torchPyTorch provides GPU-accelerated tensor…
permissive · top 1,000 on PyPI
torchaoTorchAO applies quantization and sparsity…
unclear · top 5,000 on PyPI
pte-adapter-model-explorerExtends Model Explorer with visualization…
permissive · top 15,000 on PyPI
hoptorchProvides a safe wrapper around PyTorch's scan…
permissive · top 15,000 on PyPI
litert-torchConverts PyTorch models to .tflite format for…
permissive · top 15,000 on PyPI
triton-ascendTriton Ascend is a compiler framework that…
unclear · top 15,000 on PyPI
executorchExecuTorch exports and runs PyTorch models on…
permissive · top 15,000 on PyPI
pytorchThis package is a redirect or placeholder; the…
unclear · top 15,000 on PyPI
torchcodecTorchCodec decodes and encodes videos, audio,…
unclear · top 5,000 on PyPI
torch-einops-utilsProvides utility functions for PyTorch and…
permissive · top 15,000 on PyPI