mirror of
https://github.com/modelscope/modelscope.git
synced 2026-08-29 10:08:40 +02:00
update npu dockerfile (#1755)
This commit is contained in:
@@ -10,7 +10,8 @@ ms-swift Ascend images provide a ready-to-use ms-swift environment for Huawei As
|
||||
- Build template: `docker/Dockerfile.ascend`
|
||||
- Build entrypoint: `docker/build_image.py --image_type ascend`
|
||||
- Default base image: `quay.io/ascend/cann:8.5.1-a3-ubuntu22.04-py3.11`
|
||||
- Default output tag: `${DOCKER_REGISTRY}:main-A3-py311-CANN8.5.1-ubuntu22.04-<arch>`
|
||||
- Supported base OSes: Ubuntu and openEuler, selected from the CANN base-image tag
|
||||
- Default output tag: `${DOCKER_REGISTRY}:main-cann8.5.1-torch_npu2.9.0.post2-a3-ubuntu22.04-py3.11-<arch>`
|
||||
- Ascend runtime environment is sourced from `/usr/local/Ascend/ascend-toolkit/set_env.sh`
|
||||
- If available, NNAL/ATB runtime is sourced from `/usr/local/Ascend/nnal/atb/set_env.sh`
|
||||
|
||||
@@ -22,45 +23,46 @@ The Ascend Dockerfile installs and configures:
|
||||
| --- | --- |
|
||||
| CANN | inherited from the selected `quay.io/ascend/cann` base image |
|
||||
| Python | inherited from the base image tag, for example `py3.11` |
|
||||
| PyTorch | `torch==2.9.0` |
|
||||
| torch-npu | `torch_npu==2.9.0.post2` |
|
||||
| torchvision / torchaudio | `torchvision==0.24.0`, `torchaudio==2.9.0` |
|
||||
| vLLM | source install from `vllm-project/vllm`, default branch `v0.18.0` |
|
||||
| vLLM Ascend | source install from `vllm-project/vllm-ascend`, default branch `v0.18.0` |
|
||||
| PyTorch | `torch==2.9.0` by default; configurable with `--torch_version` |
|
||||
| torch-npu | `torch_npu==2.9.0.post2` by default; configurable with `--torch_npu_version` |
|
||||
| torchvision / torchaudio | `torchvision==0.24.0`, `torchaudio==2.9.0` by default; pass both explicitly when overriding `--torch_version` |
|
||||
| vLLM | source install from `vllm-project/vllm`, default `0.18.0`; configurable with `--vllm_version` |
|
||||
| vLLM Ascend | source install from `vllm-project/vllm-ascend`, default `0.18.0`; configurable with `--vllm_ascend_version` |
|
||||
| Megatron-LM | source checkout, default branch `v0.15.3` |
|
||||
| MindSpeed | source checkout, default branch `core_r0.15.3` |
|
||||
| mcore-bridge | source checkout from `modelscope/mcore-bridge` |
|
||||
| mcore-bridge | latest release from PyPI |
|
||||
| ms-swift | source checkout from `modelscope/ms-swift`, default branch `main` |
|
||||
| ModelScope | source checkout from `modelscope/modelscope`, default branch `master` |
|
||||
| triton-ascend | `3.2.0` for CANN `8.5.*`; local wheel install of `3.2.1` for CANN `9.0.0` |
|
||||
| triton-ascend | CANN `8.5.*` defaults to `3.2.0`; CANN `9.0.*` defaults to `3.2.1`; configurable with `--triton_ascend_version` and installed from the Triton Ascend PyPI index |
|
||||
|
||||
## Supported Tag Format
|
||||
|
||||
Images built by `docker/build_image.py --image_type ascend` use this tag format:
|
||||
|
||||
```text
|
||||
${DOCKER_REGISTRY}:<swift-branch>-<atlas-hardware>-<python-tag>-<cann-version-tag>-<os-tag>-<arch>
|
||||
${DOCKER_REGISTRY}:<swift-branch>-<cann-version-tag>-torch_npu<torch-npu-version>-<atlas-hardware>-<os-tag>-<python-tag>-<arch>
|
||||
```
|
||||
|
||||
| Field | Example | Description |
|
||||
| --- | --- | --- |
|
||||
| `swift-branch` | `main` | ms-swift branch used during image build |
|
||||
| `atlas-hardware` | `A2`, `A3`, `300I`, `A5` | Derived from `--soc_version` |
|
||||
| `python-tag` | `py311` | Derived from `--python_version` |
|
||||
| `cann-version-tag` | `CANN8.5.1`, `CANN9.0.0` | Parsed from the CANN base image tag |
|
||||
| `os-tag` | `ubuntu22.04` | Parsed from the CANN base image tag |
|
||||
| `arch` | `arm`, `x86` | Derived from host architecture or `--arch` |
|
||||
| `cann-version-tag` | `cann8.5.1`, `cann9.0.0` | Parsed from the CANN base image tag |
|
||||
| `torch-npu-version` | `2.9.0.post2` | From `--torch_npu_version`; defaults to `2.9.0.post2` |
|
||||
| `atlas-hardware` | `a2`, `a3`, `300i`, `a5` | Derived from `--soc_version` |
|
||||
| `os-tag` | `ubuntu22.04`, `openeuler24.03` | Parsed from the CANN base-image tag; prevents tags for different OSes from colliding |
|
||||
| `python-tag` | `py3.11` | Parsed from the CANN base image tag |
|
||||
| `arch` | `aarch64`, `x86_64` | Derived from host architecture or `--arch` |
|
||||
|
||||
Default example on an ARM64 host:
|
||||
|
||||
```text
|
||||
${DOCKER_REGISTRY}:main-A3-py311-CANN8.5.1-ubuntu22.04-arm
|
||||
${DOCKER_REGISTRY}:main-cann8.5.1-torch_npu2.9.0.post2-a3-ubuntu22.04-py3.11-aarch64
|
||||
```
|
||||
|
||||
A2 / CANN 9.0.0 example:
|
||||
|
||||
```text
|
||||
${DOCKER_REGISTRY}:main-A2-py311-CANN9.0.0-ubuntu22.04-arm
|
||||
${DOCKER_REGISTRY}:main-cann9.0.0-torch_npu2.9.0.post2-a2-ubuntu22.04-py3.11-aarch64
|
||||
```
|
||||
|
||||
## Build Locally
|
||||
@@ -85,6 +87,39 @@ python docker/build_image.py \
|
||||
--soc_version ascend910b1
|
||||
```
|
||||
|
||||
Build an openEuler image. The system-dependency layer automatically uses `yum`; Ubuntu images continue to use `apt-get`.
|
||||
|
||||
```bash
|
||||
python docker/build_image.py \
|
||||
--image_type ascend \
|
||||
--base_image quay.io/ascend/cann:8.5.1-a3-openeuler24.03-py3.11 \
|
||||
--soc_version ascend910_9391
|
||||
```
|
||||
|
||||
Override the PyTorch stack. `--torch_version` must match the base version of
|
||||
`--torch_npu_version`; when overriding PyTorch, pass its matching torchvision
|
||||
and torchaudio versions explicitly.
|
||||
|
||||
```bash
|
||||
python docker/build_image.py \
|
||||
--image_type ascend \
|
||||
--torch_version 2.9.0 \
|
||||
--torch_npu_version 2.9.0.post2 \
|
||||
--torchvision_version 0.24.0 \
|
||||
--torchaudio_version 2.9.0
|
||||
```
|
||||
|
||||
Override the vLLM stack or triton-ascend. The vLLM version arguments select
|
||||
the matching Git tag, for example `0.18.0` selects `v0.18.0`.
|
||||
|
||||
```bash
|
||||
python docker/build_image.py \
|
||||
--image_type ascend \
|
||||
--vllm_version 0.18.0 \
|
||||
--vllm_ascend_version 0.18.0 \
|
||||
--triton_ascend_version 3.2.1
|
||||
```
|
||||
|
||||
Override Megatron or MindSpeed source branches when needed:
|
||||
|
||||
```bash
|
||||
@@ -94,11 +129,11 @@ python docker/build_image.py \
|
||||
--mindspeed_branch core_r0.15.3
|
||||
```
|
||||
|
||||
For slow networks, Linux hosts can use Docker host networking after the root `Dockerfile` is generated:
|
||||
To run the rendered Dockerfile manually, use:
|
||||
|
||||
```bash
|
||||
docker build --network host \
|
||||
-t ${DOCKER_REGISTRY}:main-A2-py311-CANN9.0.0-ubuntu22.04-arm \
|
||||
docker build \
|
||||
-t ${DOCKER_REGISTRY}:main-cann9.0.0-torch_npu2.9.0.post2-a2-ubuntu22.04-py3.11-aarch64 \
|
||||
-f Dockerfile .
|
||||
```
|
||||
|
||||
@@ -119,7 +154,7 @@ docker run --rm -it \
|
||||
-v /usr/local/Ascend/driver/version.info:/usr/local/Ascend/driver/version.info \
|
||||
-v /etc/ascend_install.info:/etc/ascend_install.info \
|
||||
-v /mnt/workspace:/mnt/workspace \
|
||||
${DOCKER_REGISTRY}:main-A2-py311-CANN9.0.0-ubuntu22.04-arm \
|
||||
${DOCKER_REGISTRY}:main-cann9.0.0-torch_npu2.9.0.post2-a2-ubuntu22.04-py3.11-aarch64 \
|
||||
bash
|
||||
```
|
||||
|
||||
@@ -147,7 +182,8 @@ pip show ms-swift modelscope torch-npu triton-ascend
|
||||
## Notes
|
||||
|
||||
- CANN, firmware, and driver versions must be compatible with each other.
|
||||
- CANN `8.5.*` and CANN `9.0.0` use different `triton-ascend` install paths in this Dockerfile.
|
||||
- Ubuntu base images install system dependencies through `apt-get`; openEuler base images install the corresponding RPM packages through `yum`.
|
||||
- `triton-ascend` is installed from `https://triton-ascend.osinfra.cn/pypi/simple`; select a version compatible with the chosen CANN, Python, and architecture.
|
||||
- The image is intended for Ascend NPU ms-swift workflows. CUDA-only packages pulled in by dependencies are removed when they conflict with NPU runtime libraries.
|
||||
- Use a fixed image tag for production jobs instead of relying on a moving branch name.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user