Using Ascend Docker Runtime in the Containerd Client
- Ascend Docker Runtime supports mounting physical chips and virtual chips. Before mounting virtual chips, refer to the Creating vNPU section to virtualize physical chips. Both static virtualization and dynamic virtualization of physical chips are supported.
- You can query the currently available physical chip IDs using the ls /dev/davinci* command, and query the currently available virtual chip IDs using the ls /dev/vdavinci* command.
- If you do not need to mount all content from the default Ascend Docker Runtime configuration file "/etc/ascend-docker-runtime.d/base.list", you can create a custom configuration file (for example, hostlog.list) to reduce the mounted content. For details, refer to the (Optional) Configuring Custom Mounted Content section.
The image-name:tag in the examples represents the image name and tag, such as "ascend-pytorch:pytorch_TAG". containerID is the container ID. When using ctr to start a container, you must specify a container ID, such as "c1".
Example 1: Mount the physical chip with chip ID 0 when starting the container.
ctr run --runtime io.containerd.runc.v2 --runc-binary /usr/local/Ascend/Ascend-Docker-Runtime/ascend-docker-runtime -t --env ASCEND_VISIBLE_DEVICES=0 {image-name:tag} {containerID} bashExample 2: Mount only NPU and management devices when starting a container. Do not mount driver-related directories.
ctr run --runc-binary /usr/local/Ascend/Ascend-Docker-Runtime/ascend-docker-runtime -t --env ASCEND_VISIBLE_DEVICES=0 --env ASCEND_RUNTIME_OPTIONS=NODRV {image-name:tag} {containerID} bashExample 3: Mount the physical chip with chip ID 0 when starting the container, and read the mount content from the custom configuration file
hostlog.ctr run --runc-binary /usr/local/Ascend/Ascend-Docker-Runtime/ascend-docker-runtime -t --env ASCEND_VISIBLE_DEVICES=0 --env ASCEND_RUNTIME_MOUNTS=hostlog {image-name:tag} {containerID} bashExample 4: When starting a container, mount the virtual chip with chip ID 100.
ctr run --runc-binary /usr/local/Ascend/Ascend-Docker-Runtime/ascend-docker-runtime -t --env ASCEND_VISIBLE_DEVICES=100 --env ASCEND_RUNTIME_OPTIONS=VIRTUAL {image-name:tag} {containerID} bashExample 5: When starting a container, slice 4 AICores from the physical chip with chip ID 0 as virtual devices and mount them into the container.
ctr run --runc-binary /usr/local/Ascend/Ascend-Docker-Runtime/ascend-docker-runtime -t --env ASCEND_VISIBLE_DEVICES=0 --env ASCEND_VNPU_SPECS=vir04 {image-name:tag} {containerID} bashExample 6: When starting a container, mount the physical chip with chip ID 0, and allow soft links in the mounted driver files (applicable only to Atlas 500 A2 Intelligent Station, Atlas 200I A2 Acceleration Module, and Atlas 200I DK A2 Developer Kit).
ctr run --runc-binary /usr/local/Ascend/Ascend-Docker-Runtime/ascend-docker-runtime -t --env ASCEND_VISIBLE_DEVICES=0 -e ASCEND_ALLOW_LINK=True {image-name:tag} {containerID} bash
The parameters related to the startup command are shown in Table 1.
After the container is started, you can run the following commands to check whether the corresponding devices and drivers are mounted successfully. For the specific mount directories of each model, refer to Content Mounted by Ascend Docker Runtime. The command example is as follows:
ls /dev | grep davinci* && ls /dev | grep devmm_svm && ls /dev | grep hisi_hdc && ls /usr/local/Ascend/driver && ls /usr/local/ |grep dcmi && ls /usr/local/binPossible output results are as follows:
davinci0
davinci_manager
devmm_svm
hisi_hdc
include lib64
dcmi
npu-smi
During use, do not redefine or fix environment variables such as ASCEND_VISIBLE_DEVICES, ASCEND_RUNTIME_OPTIONS, ASCEND_RUNTIME_MOUNTS, and ASCEND_VNPU_SPECS in the container image.
Table 1 Ascend Docker Runtime parameters
| Parameter | Description | Example |
|---|---|---|
| ASCEND_VISIBLE_DEVICES |
|
|
| ASCEND_ALLOW_LINK | Whether to allow soft links in the mounted files or directories. This parameter needs to be specified in scenarios involving the Atlas 500 A2 Intelligent Station, Atlas 200I A2 AI Acceleration Module, and Atlas 200I DK A2 Developer Kit. Other devices, such as Atlas training series products, |
|
| ASCEND_RUNTIME_OPTIONS | Restricts the chip ID specified in the ASCEND_VISIBLE_DEVICES parameter:
|
Note:
|
| ASCEND_RUNTIME_MOUNTS | The configuration file name for the content to be mounted. This file can configure the files and directories to be mounted into the container. |
|
| ASCEND_VNPU_SPECS | Partitions a certain number of AICores from a physical NPU device and specifies them as a virtual device. For supported values, see the "Virtualization Instance Template" column in Table 1 of Virtualization Templates.
| ASCEND_VNPU_SPECS=vir04 indicates that 4 AICores are partitioned as a virtual device and mounted into the container. |