Usage on the Docker Client

Usage Instructions

  • Ascend Docker Runtime supports mounting physical and virtual chips. Before mounting virtual chips, refer to Creating vNPUs to virtualize physical chips. Both static virtualization and dynamic virtualization of physical chips are supported.
  • You can query the currently available physical chip IDs by running the ls /dev/davinci* command, and query the currently available virtual chip IDs by running the ls /dev/vdavinci* command.
  • If you do not need to mount all the content in the default configuration file /etc/ascend-docker-runtime.d/base.list of Ascend Docker Runtime, create a custom configuration file (for example, hostlog.list) to reduce the mounted content. For details, see (Optional) Configuring Custom Mounted Content.

Mounting Chips Using Ascend Docker Runtime

In the examples, image-name:tag represents the image name and tag. For details about other parameters, see Table 1.

  • Example 1: Mount the physical chip with chip ID 0 when starting the container.

    docker run -it -e ASCEND_VISIBLE_DEVICES=0 {image-name:tag} /bin/bash
  • Example 2: Mount only the NPU device and management device when starting the container, without mounting 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 the physical chip with chip ID 0 when starting the container, and read the mount content from the custom configuration file hostlog.list.

    docker run --rm -it -e ASCEND_VISIBLE_DEVICES=0 -e ASCEND_RUNTIME_MOUNTS=hostlog {image-name:tag} /bin/bash
  • Example 4: Mount the chip with virtual chip ID 100 when starting the container.

    docker run -it -e ASCEND_VISIBLE_DEVICES=100 -e ASCEND_RUNTIME_OPTIONS=VIRTUAL {image-name:tag} /bin/bash
  • Example 5: When starting the container, slice 4 AICores from the chip with physical chip ID 0 as virtual devices and mount them to the container.

    docker run -it --rm -e ASCEND_VISIBLE_DEVICES=0 -e ASCEND_VNPU_SPECS=vir04 {image-name:tag} /bin/bash
  • Example 6: When starting the container, mount the chip with physical chip ID 0, and allow soft links in the mounted driver files (applicable only to Atlas 500 A2 intelligent station, Atlas 200I A2 accelerator module, and Atlas 200I DK A2):

    docker run --rm -it -e ASCEND_VISIBLE_DEVICES=0 -e ASCEND_ALLOW_LINK=True {image-name:tag} /bin/bash

After the container is started, run the following commands inside and outside the container to check whether the corresponding devices and drivers are mounted successfully. For the specific mount directory of each model, refer to Content Mounted by Ascend Docker Runtime. Example commands are 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/bin

Possible outputs:

davinci0
davinci_manager
devmm_svm
hisi_hdc
include lib64
dcmi
npu-smi

Using Ascend Docker Runtime to Mount Chips and Other Devices

Use Ascend Docker Runtime to support containers running training, inference, or other tasks.

  • Taking the Atlas 200I SoC A1 core board running an inference container as an example, modify the command according to the actual situation. The example is as follows, and the related parameters are shown in Table 1 and Table 2.

    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 /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

    NOTE

    • If the driver of the Atlas 200I SoC A1 core board is version 1.0.0 (Ascend HDK 22.0.0) or earlier, you need to mount /dev/xsmem_dev and /dev/event_sched.
    • If the driver of the Atlas 200I SoC A1 core board is later than version 1.0.0 (Ascend HDK 22.0.0), you do not need to mount /dev/xsmem_dev and /dev/event_sched.
  • Taking the Atlas 500 A2 intelligent station running an inference container as an example, modify the command according to the actual situation. The example is as follows, and the related parameters are shown in Table 1 and Table 2.

    docker run --rm -it -e ASCEND_VISIBLE_DEVICES=0 -e ASCEND_ALLOW_LINK=True workload-image:v1.0 /bin/bash

Mounting Chips and Other Devices Without Ascend Docker Runtime

  • Taking the Atlas 200I SoC A1 core board running an inference container as an example, modify the command according to the actual situation. The example is as follows, and the related parameters are shown in Table 2.

    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 /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 of the Atlas 200I SoC A1 core board is version 1.0.0 (Ascend HDK 22.0.0) or earlier, you need to mount /dev/xsmem_dev and /dev/event_sched.
    • If the driver of the Atlas 200I SoC A1 core board is a version later than 1.0.0 (Ascend HDK 22.0.0), you do not need to mount /dev/xsmem_dev and /dev/event_sched.
  • To run inference tasks on the Atlas 500 A2 intelligent station without using Ascend Docker Runtime, refer to the "Starting the Container" section in "Deploying Ascend Software (Customized System Scenario) > Container Deployment > Creating a Container Image" in the Atlas 500 A2 Intelligent Station Ascend Software Installation Guide.

Parameter Description

Table 1 Ascend Docker Runtime running parameters

ParameterDescriptionExample
ASCEND_VISIBLE_DEVICES
  • If the task does not require an NPU device, you can set the ASCEND_VISIBLE_DEVICES environment variable to void or leave it empty.
  • If the task requires an NPU device, you must use ASCEND_VISIBLE_DEVICES to specify the NPU device to be mounted to the container; otherwise, the NPU device mount will fail. When specifying devices by device ID, single IDs, ranges, and a mix of both are supported.
  • If the task requires an NPU device, you must use ASCEND_VISIBLE_DEVICES to specify the NPU device to be mounted to the container; otherwise, the NPU device mount will fail. When specifying devices by device ID, single IDs, ranges, and a mix of both are supported; when specifying devices by chip name, multiple chip names of the same type can be specified simultaneously.
  • ASCEND_VISIBLE_DEVICES=void indicates that the mount function of Ascend Docker Runtime is not used, and no NPU device, driver, or file directory is mounted. Related mount parameters will also become invalid.
  • Mount physical chip (NPU)
    • ASCEND_VISIBLE_DEVICES=0 indicates that NPU device 0 (/dev/davinci0) is mounted to the container.
    • ASCEND_VISIBLE_DEVICES=1,3 indicates that NPU devices 1 and 3 are mounted to the container.
    • ASCEND_VISIBLE_DEVICES=0-2 indicates that NPU devices 0 through 2 (including 0 and 2) are mounted to the container, with the same effect as -e ASCEND_VISIBLE_DEVICES=0,1,2.
    • ASCEND_VISIBLE_DEVICES=0-2,4 indicates that NPU devices 0 through 2 and device 4 are mounted to the container, with the same effect as -e ASCEND_VISIBLE_DEVICES=0,1,2,4.
    • ASCEND_VISIBLE_DEVICES=XXX-Y, where XXX represents the NPU device, with supported values being npu, Ascend910, Ascend310, Ascend310B, and Ascend310P; Y represents the physical NPU device ID.
      • ASCEND_VISIBLE_DEVICES=npu-1 indicates that NPU device 1 is mounted to the container.
      • ASCEND_VISIBLE_DEVICES=npu-1,npu-3 indicates that NPU 1 and NPU 3 are mounted to the container.
    NOTE
    • When specifying devices by chip name, it is recommended to use the value npu uniformly.
    • Specifying both a device ID and an NPU name in a single parameter is not supported, meaning ASCEND_VISIBLE_DEVICES=0,npu-1 is not supported.
  • Mount virtual chip (vNPU)
    • Static virtualization: The usage is the same as for physical chips; simply replace the physical chip ID with the virtual chip ID (vNPU ID).
    • Dynamic virtualization: ASCEND_VISIBLE_DEVICES=0 indicates that a certain number of AICores are partitioned from NPU device 0.
      NOTE
      • A single dynamic virtualization command can only specify the ID of one physical NPU for dynamic virtualization.
      • Must be used together with ASCEND_VNPU_SPECS, which indicates the number of AICores partitioned on the specified NPU.
      • Can be used together with ASCEND_RUNTIME_OPTIONS, but only the value NODRV is allowed, indicating that driver-related directories are not mounted.
ASCEND_ALLOW_LINKSpecifies whether soft links are allowed in the mounted files or directories. This parameter must be specified in scenarios involving the Atlas 500 A2 Smart Station, Atlas 200I A2 acceleration module, and Atlas 200I DK A2 developer kit.

Other devices, such as Atlas training series products, Atlas A2 training series products, and the Atlas 200I SoC A1 core board, can use this parameter, but since soft links do not exist in their default mount content, specifying this parameter is unnecessary.

  • ASCEND_ALLOW_LINK=True indicates that mounting driver files with soft links is allowed in scenarios involving the Atlas 500 A2 Smart Station, Atlas 200I A2 acceleration module, and Atlas 200I DK A2 developer kit.
  • If ASCEND_ALLOW_LINK=False or this parameter is not specified, Ascend Docker Runtime cannot be used on the Atlas 500 A2 Smart Station, Atlas 200I A2 acceleration module, and Atlas 200I DK A2 developer kit.
ASCEND_RUNTIME_OPTIONSRestricts the chip ID specified in the ASCEND_VISIBLE_DEVICES parameter:
  • NODRV: Indicates that driver-related directories are not mounted.
  • VIRTUAL: Indicates that a virtual chip is mounted.
  • NODRV,VIRTUAL: Indicates that a virtual chip is mounted and driver-related directories are not mounted.
  • ASCEND_RUNTIME_OPTIONS=NODRV
  • ASCEND_RUNTIME_OPTIONS=VIRTUAL
  • ASCEND_RUNTIME_OPTIONS=NODRV,VIRTUAL
NOTE
  • In static virtualization scenarios, ASCEND_RUNTIME_OPTIONS is a required parameter, and its value must include VIRTUAL.
  • In dynamic virtualization scenarios, if the ASCEND_RUNTIME_OPTIONS parameter is used, its value cannot include VIRTUAL.
ASCEND_RUNTIME_MOUNTSSpecifies the configuration file name for the content to be mounted. This file can configure the files and directories to be mounted to the container.
  • ASCEND_RUNTIME_MOUNTS=base
  • ASCEND_RUNTIME_MOUNTS=hostlog
  • ASCEND_RUNTIME_MOUNTS=hostlog,hostlog1,hostlog2
    NOTE
    • By default, the /etc/ascend-docker-runtime.d/base.list configuration file is read.
    • For hostlog.list, modify it according to the actual custom configuration file name.
    • Reading multiple custom configuration files is supported.
    • File names must be lowercase and cannot contain uppercase letters. File names containing uppercase letters may cause the configuration file to fail to take effect.
ASCEND_VNPU_SPECSPartitions a certain number of AICores from a physical NPU device and specifies them as virtual devices. For supported values, see the "Virtualization Instance Template" column in Table 1 of Virtualization Templates.
  • This parameter can only be used for product forms that support dynamic virtualization.
  • Must be used together with the "ASCEND_VISIBLE_DEVICES" parameter, which specifies the physical NPU device used for virtualization.
  • When the value of the ASCEND_RUNTIME_OPTIONS parameter includes VIRTUAL, the ASCEND_VNPU_SPECS parameter will no longer take effect.
ASCEND_VNPU_SPECS=vir04 indicates that 4 AICores are partitioned as virtual devices and mounted to the container.

Table 2 Explanation of other parameters

ParameterDescription
/dev/xsmem_devMounts the memory device management to the container.
/dev/event_schedMounts the event scheduling device to the container.
/dev/ts_aisleMounts the device corresponding to the aicpudrv driver to the container.
/dev/svm0Mounts the memory management device to the container.
/dev/sysMounts dvpp-related devices to the container.
/dev/vdecMounts dvpp-related devices to the container.
/dev/vpcMounts dvpp-related devices to the container.
/dev/log_drvMounts the logging-related device to the container.
/dev/upgradeMounts the device for obtaining Ascend system-related configurations and firmware to the container.
/dev/spi_smbusMounts the device related to out-of-band SPI communication to the container.
/dev/user_configMounts the device for managing user configurations to the container.
/dev/memory_bandwidthMounts the memory bandwidth-related device to the container.
-v /var/slogd:/var/slogdMounts the host machine log process file to the container in read-only mode.
-v /var/dmp_daemon:/var/dmp_daemonMounts the dmp daemon to the container.
-v /var/log/npu/conf/slog:/var/log/npu/conf/slogMounts the NPU log module to the container.
-v /usr/lib64/libyaml-0.so.2:/usr/lib64/libyaml-0.so.2:roMounts the host machine libyaml .so file to the container.
-v /usr/local/Ascend/driver/tools:/usr/local/Ascend/driver/toolsMounts the driver-related tools directory "/usr/local/Ascend/driver/tools" to the container.
-v /usr/local/Ascend/driver/lib64:/usr/local/Ascend/driver/lib64Mounts the driver-dependent dynamic library directory "/usr/local/Ascend/driver/lib64" to the container.
-v /usr/lib64/aicpu_kernels:/usr/lib64/aicpu_kernelsMounts the aicpu lib library directory "/usr/lib64/aicpu_kernels" to the container.
-v /sys/fs/cgroup/memory:/sys/fs/cgroup/memory:roMounts the dependency directory "/sys/fs/cgroup/memory" required for querying memory usage on the host machine to the container in read-only mode.
-v /etc/ascend_install.info:/etc/ascend_install.infoMounts the host machine installation information file "/etc/ascend_install.info" to the container.
-v /usr/local/Ascend/driver/version.info:/usr/local/Ascend/driver/version.infoMounts the host machine version information file "/usr/local/Ascend/driver/version.info" to the container. Modify it based on the actual situation.
workload-image:v1.0The generated image file.
/bin/bashStarts an interactive terminal Bash Shell in the container.