Usage on the Docker Client
Usage Instruction
- 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.
Using Ascend Docker Runtime to Mount Processors
- Example 1: Mount a processor whose physical processor ID is 0 when starting a container.
docker run -it -e ASCEND_VISIBLE_DEVICES=0 image-name:tag /bin/bash
- Example 2: Mount only NPU and management devices when starting a container. Do not mount driver-related directories.
docker run --rm -it -e ASCEND_VISIBLE_DEVICES=0 -e ASCEND_RUNTIME_OPTIONS=NODRV image-name:tag /bin/bash
- Example 3: Mount a processor whose physical processor ID is 0 and read the mounted content of hostlog.list when starting a container.
docker run --rm -it -e ASCEND_VISIBLE_DEVICES=0 -e ASCEND_RUNTIME_MOUNTS=hostlog image-name:tag /bin/bash
- Example 4: Mount a processor whose virtual processor ID is 100 when starting a container.
docker run -it -e ASCEND_VISIBLE_DEVICES=100 -e ASCEND_RUNTIME_OPTIONS=VIRTUAL image-name:tag /bin/bash
- 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.
docker run -it --rm -e ASCEND_VISIBLE_DEVICES=0 -e ASCEND_VNPU_SPECS=vir04 image-name:tag /bin/bash
- 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).
docker run --rm -it -e ASCEND_VISIBLE_DEVICES=0 -e ASCEND_ALLOW_LINK=True image-name:tag /bin/bash
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
Using Ascend Docker Runtime to Mount Processors and Other Devices
Ascend Docker Runtime can be used to enable containers to run training, inference, or other jobs.
- The following uses an Atlas 200I SoC A1 core board as an example to describe how to run an inference container. Change options in commands as required. Table 1 and Table 2 describe related options.
docker run -it -e ASCEND_VISIBLE_DEVICES=0 --device=/dev/xsmem_dev:rwm --device=/dev/event_sched:rwm --device=/dev/svm0:rwm --device=/dev/sys:rwm --device=/dev/vdec:rwm --device=/dev/vpc:rwm --device=/dev/log_drv:rwm --device=/dev/spi_smbus:rwm --device=/dev/upgrade:rwm --device=/dev/user_config:rwm --device=/dev/ts_aisle:rwm --device=/dev/memory_bandwidth:rwm -v /var/dmp_daemon:/var/dmp_daemon:ro -v /var/slogd:/var/slogd:ro -v /var/log/npu/conf/slog/slog.conf:/var/log/npu/conf/slog/slog.conf:ro -v /usr/local/Ascend/driver/tools:/usr/local/Ascend/driver/tools -v /usr/local/Ascend/driver/lib64:/usr/local/Ascend/driver/lib64 -v /usr/lib64/aicpu_kernels:/usr/lib64/aicpu_kernels:ro -v /usr/lib64/libtensorflow.so:/usr/lib64/libtensorflow.so:ro -v /sys/fs/cgroup/memory:/sys/fs/cgroup/memory:ro -v /usr/lib64/libyaml-0.so.2:/usr/lib64/libyaml-0.so.2:ro -v /etc/ascend_install.info:/etc/ascend_install.info -v /usr/local/Ascend/driver/version.info:/usr/local/Ascend/driver/version.info workload-image:v1.0 /bin/bash
- If the driver version of the Atlas 200I SoC A1 core board is 1.0.0 (Ascend HDK 22.0.0) or earlier, you need to mount /dev/xsmem_dev and /dev/event_sched.
- If the driver version of the Atlas 200I SoC A1 core board is later than 1.0.0 (Ascend HDK 22.0.0), you do not need to mount /dev/xsmem_dev and /dev/event_sched.
- The following uses an Atlas 500 A2 edge station as an example to describe how to run an inference container. Change options in commands as required. Table 1 and Table 2 describe related options.
docker run --rm -it -e ASCEND_VISIBLE_DEVICES=0 -e ASCEND_ALLOW_LINK=True workload-image:v1.0 /bin/bash
Not Using Ascend Docker Runtime to Mount Processors or Other Devices
- The following uses an Atlas 200I SoC A1 core board as an example to describe how to run an inference container. Change options in commands as required. Table 2 describes related options.
docker run -it --device=/dev/davinci0:rwm --device=/dev/xsmem_dev:rwm --device=/dev/event_sched:rwm --device=/dev/svm0:rwm --device=/dev/sys:rwm --device=/dev/vdec:rwm --device=/dev/venc:rwm --device=/dev/vpc:rwm --device=/dev/davinci_manager:rwm --device=/dev/spi_smbus:rwm --device=/dev/upgrade:rwm --device=/dev/user_config:rwm --device=/dev/ts_aisle:rwm --device=/dev/memory_bandwidth:rwm -v /etc/sys_version.conf:/etc/sys_version.conf:ro -v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi:ro -v /var/dmp_daemon:/var/dmp_daemon:ro -v /var/slogd:/var/slogd:ro -v /var/log/npu/conf/slog/slog.conf:/var/log/npu/conf/slog/slog.conf:ro -v /etc/hdcBasic.cfg:/etc/hdcBasic.cfg:ro -v /usr/local/Ascend/driver/tools:/usr/local/Ascend/driver/tools -v /usr/local/Ascend/driver/lib64:/usr/local/Ascend/driver/lib64 -v /usr/lib64/aicpu_kernels:/usr/lib64/aicpu_kernels:ro -v /usr/lib64/libtensorflow.so:/usr/lib64/libtensorflow.so:ro -v /sys/fs/cgroup/memory:/sys/fs/cgroup/memory:ro -v /usr/lib64/libyaml-0.so.2:/usr/lib64/libyaml-0.so.2:ro -v /etc/ascend_install.info:/etc/ascend_install.info -v /usr/local/Ascend/driver/version.info:/usr/local/Ascend/driver/version.info workload-image:v1.0 /bin/bash
- If the driver version of the Atlas 200I SoC A1 core board is 1.0.0 (Ascend HDK 22.0.0) or earlier, mount /dev/xsmem_dev and /dev/event_sched.
- If the driver version of Atlas 200I SoC A1 core board is later than 1.0.0 (Ascend HDK 22.0.0), you do not need to mount /dev/xsmem_dev and /dev/event_sched.
- The Atlas 500 A2 edge station does not use Ascend Docker Runtime to run inference jobs.
Parameter Description
Parameter |
Description |
Example |
|---|---|---|
ASCEND_VISIBLE_DEVICES |
|
|
ASCEND_ALLOW_LINK |
Specifies whether soft links are allowed in the mounted file or directory. This parameter must be specified for the Atlas 500 A2 edge station, Atlas 200I A2 accelerator module, and Atlas 200I DK A2 developer kit. 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. NOTE:
If the value of ASCEND_RUNTIME_OPTIONS contains VIRTUAL, ASCEND_VNPU_SPECS does not take effect. |
ASCEND_VNPU_SPECS=vir04 indicates that four AI Cores are used as virtual devices and mounted to the container. NOTE:
|
Parameter |
Parameter Description |
|---|---|
/dev/xsmem_dev |
Mounts the device that manages the memory to the container. |
/dev/event_sched |
Mounts the device for event scheduling to the container. |
/dev/ts_aisle |
Mounts the device corresponding to the aicpudrv driver to the container. |
/dev/svm0 |
Mounts the device for memory management to the container. |
/dev/sys |
Mounts the DVPP-related device to the container. |
/dev/vdec |
Mounts the DVPP-related device to the container. |
/dev/vpc |
Mounts the DVPP-related device to the container. |
/dev/log_drv |
Mounts the device that records logs to the container. |
/dev/upgrade |
Mounts the device that obtains the Ascend system configuration and firmware information to the container. |
/dev/spi_smbus |
Mounts the device that uses out-of-band SPI communication to the container. |
/dev/user_config |
Mounts the device that is related to the management user configuration to the container. |
/dev/memory_bandwidth |
Mounts the device that is related to the memory bandwidth to the container. |
-v /var/slogd:/var/slogd |
Mounts the log process file of the host to the container in read-only mode. |
-v /var/dmp_daemon:/var/dmp_daemon |
Mounts the DMP daemon to the container. |
-v /var/log/npu/conf/slog:/var/log/npu/conf/slog |
Mounts the NPU log module to the container. |
-v /usr/lib64/libyaml-0.so.2:/usr/lib64/libyaml-0.so.2:ro |
Mounts the .so file of libyaml on the host to the container. |
-v /usr/local/Ascend/driver/tools:/usr/local/Ascend/driver/tools |
Mounts /usr/local/Ascend/driver/tools (driver-related tool directory) to the container. |
-v /usr/local/Ascend/driver/lib64:/usr/local/Ascend/driver/lib64 |
Mounts /usr/local/Ascend/driver/lib64 (dynamic library directory of the driver dependency) to the container. |
-v /usr/lib64/libtensorflow.so:/usr/lib64/libtensorflow.so |
Mounts /usr/lib64/libtensorflow.so (AI CPU operator library file of TensorFlow) to the container. |
-v /usr/lib64/aicpu_kernels:/usr/lib64/aicpu_kernels |
Mounts /usr/lib64/aicpu_kernels (AI CPU operator library directory) to the container. |
-v /sys/fs/cgroup/memory:/sys/fs/cgroup/memory:ro |
Mounts the /sys/fs/cgroup/memory directory required for querying the host memory usage to the container in read-only mode. |
-v /etc/ascend_install.info:/etc/ascend_install.info |
Mounts the host installation information file /etc/ascend_install.info to the container. |
-v /usr/local/Ascend/driver/version.info:/usr/local/Ascend/driver/version.info |
Mounts the host version information file /usr/local/Ascend/driver/version.info to the container. Modify the file according to your actual requirements. |
workload-image:v1.0 |
Indicates the generated image file. |
/bin/bash |
Starts the interactive Bash Shell in the container. |