Usage on the Containerd Client
Usage Instruction
- Before using Ascend Docker Runtime on the Containerd client, you need to check the current cgroup version. Run the stat -fc %T /sys/fs/cgroup/ command. If tmpfs is displayed, cgroup v1 is used. If cgroup2fs is displayed, cgroup v2 is used.
- Ascend Docker Runtime supports both physical and virtual processors. Before mounting a virtual processor, virtualize the corresponding physical processor statically or dynamically by referring to Creating vNPUs.
- You can run the ls /dev/davinci* and ls /dev/vdavinci* commands to query the IDs of available physical and virtual processors, respectively.
- If you do not need to mount all content in the default configuration file /etc/ascend-docker-runtime.d/base.list of Ascend Docker Runtime, you can create a custom configuration file (for example, hostlog.list) to reduce the content to be mounted. For details, see (Optional) Configuring Custom Mounted Content.
Usage Examples
In the following examples, image-name:tag indicates the image name and tag, for example, ascend-tensorflow:tensorflow_TAG. containerID indicates the container ID. If you use the ctr command to start a container, you need to specify the container ID, for example, c1.
- Example 1: Mount a processor whose physical processor ID is 0 when starting a container.
- cgroup v1
ctr run --runtime io.containerd.runtime.v1.linux -t --env ASCEND_VISIBLE_DEVICES=0 image-name:tag containerID bash
- cgroup v2
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 bash
- cgroup v1
- Example 2: Mount only NPU and management devices when starting a container. Do not mount driver-related directories.
- cgroup v1
ctr run --runtime io.containerd.runtime.v1.linux -t --env ASCEND_VISIBLE_DEVICES=0 --env ASCEND_RUNTIME_OPTIONS=NODRV image-name:tag containerID bash
- cgroup v2
ctr run --runtime io.containerd.runc.v2 --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 bash
- cgroup v1
- Example 3: Mount a processor whose physical processor ID is 0 and read the mounted content of the custom configuration file hostlog when starting a container.
- cgroup v1
ctr run --runtime io.containerd.runtime.v1.linux -t --env ASCEND_VISIBLE_DEVICES=0 --env ASCEND_RUNTIME_MOUNTS=hostlog image-name:tag containerID bash
- cgroup v2
ctr run --runtime io.containerd.runc.v2 --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 bash
- cgroup v1
- Example 4: Mount a processor whose virtual processor ID is 100 when starting a container.
- cgroup v1
ctr run --runtime io.containerd.runtime.v1.linux -t --env ASCEND_VISIBLE_DEVICES=100 --env ASCEND_RUNTIME_OPTIONS=VIRTUAL image-name:tag containerID bash
- cgroup v2
ctr run --runtime io.containerd.runc.v2 --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 bash
- cgroup v1
- Example 5: Split four AI Cores from a processor whose physical processor ID is 0 as virtual devices and mount them to a container when starting the container.
- cgroup v1
ctr run --runtime io.containerd.runtime.v1.linux -t --env ASCEND_VISIBLE_DEVICES=0 --env ASCEND_VNPU_SPECS=vir04 image-name:tag containerID bash
- cgroup v2
ctr run --runtime io.containerd.runc.v2 --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 bash
- cgroup v1
- Example 6: Mount a processor whose physical processor ID is 0 and allow for soft links in the mounted driver file when starting a container (applicable only to the Atlas 500 A2 edge station, Atlas 200I A2 accelerator module, and Atlas 200I DK A2 developer kit).
- cgroup v1
ctr run --runtime io.containerd.runtime.v1.linux -t --env ASCEND_VISIBLE_DEVICES=0 -e ASCEND_ALLOW_LINK=True image-name:tag containerID bash
- cgroup v2
ctr run --runtime io.containerd.runc.v2 --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
- cgroup v1
For details about the parameters in the startup command, see Table 1.
After a container is started, check whether related devices and drivers are successfully mounted. For details about the mounted directory of each model, see Default Content Mounted by Ascend Docker Runtime. Example command:
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/bin
Do not repeatedly define or fix environment variables such as ASCEND_VISIBLE_DEVICES, ASCEND_RUNTIME_OPTIONS, ASCEND_RUNTIME_MOUNTS, and ASCEND_VNPU_SPECS in the container image.
Parameter |
Description |
Example |
|---|---|---|
ASCEND_VISIBLE_DEVICES |
|
|
ASCEND_ALLOW_LINK |
Specifies whether soft links are allowed in the mounted file or directory. This parameter needs to be specified in for the Atlas 500 A2 edge station, Atlas 200I A2 AI accelerator module, and Atlas 200I DK A2. NOTE:
Other devices such as Atlas training product, |
|
ASCEND_RUNTIME_OPTIONS |
Restricts the processor ID specified by ASCEND_VISIBLE_DEVICES.
|
|
ASCEND_RUNTIME_MOUNTS |
Name of the configuration file with content to be mounted. You can configure the files and directories to be mounted to the container in this file. |
|
ASCEND_VNPU_SPECS |
Splits a certain number of AI Cores from a physical NPU device and specifies them as virtual devices. The following values are supported:
This parameter must be used together with ASCEND_VISIBLE_DEVICES that specifies the physical NPU device to be split. |
ASCEND_VNPU_SPECS=vir04 indicates that four AI Cores are used as virtual devices and mounted to the container. NOTE:
|