Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions _additional_platforms/ascend_npu.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "Ascend NPU",
"support_channel": "https://github.com/Ascend/pytorch/issues",
"stable": {
"linux": "pip3 install torch torchvision && pip3 install torch-npu"
}
}
65 changes: 65 additions & 0 deletions _get_started/additional_platforms/ascend_npu.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Installing on Ascend NPU

Ascend NPU is Huawei's AI processor series (including Ascend 910B, 910C, and 310P). The Ascend Extension for PyTorch (`torch_npu`) enables PyTorch to run on Ascend NPUs, supporting eager-mode execution, distributed training, and mixed precision via the `PrivateUse1` backend.

## Prerequisites

### Hardware Requirements

* Ascend 910B, 910C, or 310P processor

### Software Requirements

* Python >= 3.10
* CANN (Compute Architecture for Neural Networks) toolkit installed >= 8.0
* Ascend driver and firmware installed

Before installing PyTorch with Ascend NPU support, you must install the CANN toolkit. Download it from the [Ascend Community](https://www.hiascend.com/) and follow the [CANN Installation Guide](https://www.hiascend.com/cann/download?versionId=735&ids=d806%2Ch0501%2Ch0601%2Ch0702).

## Installation

### pip

Use the pip package manager to install PyTorch with Ascend NPU support. Select your preferred options in the selector above to get the installation command.

After installation, source the CANN environment:

```bash
source <ASCEND_INSTALL_DIR>/Ascend/cann/set_env.sh
source <ASCEND_INSTALL_DIR>/Ascend/nnal/atb/set_env.sh
```

## Verification

To ensure that PyTorch was installed correctly with Ascend NPU support, run the following code:

```python
import torch
import torch_npu

print(torch.__version__)
print("torch_npu version:", torch_npu.__version__)

if torch.npu.is_available():
print("Ascend NPU is available!")
print(f"NPU count: {torch_npu.npu.device_count()}")
print(f"NPU name: {torch_npu.npu.get_device_name(0)}")

# Test basic computation
a = torch.randn(3, 4).npu()
b = torch.randn(3, 4).npu()
print("NPU computation result:", a + b)
else:
print("Ascend NPU is not available.")
```

Expected output should show the PyTorch and torch_npu versions, NPU count, device name, and the result of a tensor addition without errors.

## Documentation

For more information, please visit:

* [Ascend Extension for PyTorch Official Documentation](https://www.hiascend.com/document/detail/zh/Pytorch/2600/index/index.html)
* [Ascend Community Portal](https://www.hiascend.com/)
* [Ascend/pytorch GitHub Repository](https://github.com/Ascend/pytorch)
* [PyPI: torch-npu](https://pypi.org/project/torch-npu/)