Using on the Docker Client

The following is an example of the command for starting a container using Ascend Docker Runtime on the Docker client:
  • 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 the custom configuration file hostlog 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 the 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

After the container is started, you can run the 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 command to check whether the corresponding devices and drivers are successfully mounted. For details about the mounted directories of each server model, see Default Content Mounted by the Ascend Docker Runtime.

When containers are used to run training, inference, or other jobs, the following situations may occur:

Ascend Docker Runtime used:

The following uses the Atlas 200I Soc A1 core board as an example to describe how to run the inference container. Change the value based on your needs. The following is an example. Table 1 and Table 2 describes the related parameters.

docker run -it -e ASCEND_VISIBLE_DEVICES=0 --device=/dev/xsmem_dev --device=/dev/event_sched --device=/dev/svm0 --device=/dev/sys --device=/dev/vdec --device=/dev/vpc --device=/dev/log_drv --device=/dev/spi_smbus --device=/dev/upgrade --device=/dev/user_config --device=/dev/ts_aisle --device=/dev/memory_bandwidth -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 /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

Ascend Docker Runtime not used:

The following uses the Atlas 200I SoC A1 core board as an example to describe how to run the inference container. Change the value based on your needs. The following is an example. Table 1 and Table 2 describes the related parameters.

docker run -it --device=/dev/davinci0 --device=/dev/xsmem_dev --device=/dev/event_sched --device=/dev/svm0 --device=/dev/sys --device=/dev/vdec --device=/dev/venc --device=/dev/vpc --device=/dev/davinci_manager --device=/dev/spi_smbus --device=/dev/upgrade --device=/dev/user_config --device=/dev/ts_aisle --device=/dev/memory_bandwidth -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 /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
Table 1 Ascend Docker Runtime parameters

Parameter

Description

Example

ASCEND_VISIBLE_DEVICES

Uses the ASCEND_VISIBLE_DEVICES environment variable to specify the NPU device to be mounted to the container, and uses the device sequence number to specify the device. You can specify a single device or a device range, or both of them.

  • ASCEND_VISIBLE_DEVICES=0 indicates that device 0 (/dev/davinci0) is mounted to the container.
  • ASCEND_VISIBLE_DEVICES=1,3 indicates that devices 1 and 3 are mounted to the container.
  • ASCEND_VISIBLE_DEVICES=0-2 indicates that devices 0 to 2 (including devices 0 and 2) are mounted to the container. The effect is the same as that of -e ASCEND_VISIBLE_DEVICES=0,1,2.
  • ASCEND_VISIBLE_DEVICES=0-2,4 indicates that devices 0 to 2 and device 4 are mounted to the container. The effect is the same as that of -e ASCEND_VISIBLE_DEVICES=0,1,2,4.

ASCEND_RUNTIME_OPTIONS

Restricts the processor ID specified by ASCEND_VISIBLE_DEVICES.

  • NODRV indicates that driver-related directories are not mounted.
  • VIRTUAL indicates that the virtual processor is mounted.
  • NODRV,VIRTUAL indicates that the virtual processor is mounted while driver-related directories are not mounted.
NOTE:

For details about the restrictions and creation methods of virtual devices, see "Installation in the Computing Power Allocation Scenario" in the Ascend 910 NPU Driver and Firmware Installation Guide (AI Server). For details about other product models, see the corresponding driver and firmware installation manuals.

  • ASCEND_RUNTIME_OPTIONS=NODRV
  • ASCEND_RUNTIME_OPTIONS=VIRTUAL
  • ASCEND_RUNTIME_OPTIONS=NODRV,VIRTUAL

ASCEND_RUNTIME_MOUNTS

Reads the mounted content in the configuration file.

ASCEND_RUNTIME_MOUNTS=hostlog
NOTE:

Change hostlog to the actual configuration file name.

ASCEND_VNPU_SPECS

Splits a certain number of AI Cores from a physical NPU device and specifies them as virtual devices. The value can be vir01, vir02, vir02_1c, vir04, vir04_3c, vir08, vir16, vir04_4c_dvpp, or vir04_3c_ndvpp.

  • vir01, vir02, vir02_1c, vir04, vir04_3c, vir04_4c_dvpp, and vir04_3c_ndvpp for Atlas inference products
  • vir02, vir04, vir08, and vir16 for Atlas training products

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 a container.

NOTE:
  • The number following vir indicates the number of AI Cores.
  • The number before c indicates the number of AI CPUs.
  • dvpp indicates that all digital vision pre-processing (DVPP) modules (VPC, VDEC, JPEGD, PNGD, VENC and JPEGE) are included during virtualization.
  • ndvpp indicates that DVPP hardware resources are excluded during virtualization.
Table 2 Description of other parameters

Parameter

Parameters

/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 DMP log directory to the container.

-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/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 library file of TensorFlow) to the container.

-v /usr/lib64/aicpu_kernels:/usr/lib64/aicpu_kernels

Mounts /usr/lib64/aicpu_kernels (AI CPU 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 /bin/bash

Generated image file.

  • You can query the available processor IDs as follows:
    • Physical processor ID:
      ls /dev/davinci*
    • Virtual processor ID:
      ls /dev/vdavinci*
  • image-name:tag: image name and tag. Change them as required. Change it as required.
  • If you do not need to mount all content in the basic configuration file base, specify the mounted content to be reduced in hostlog. Change hostlog to the actual configuration file name.

    The mounted content of hostlog must be based on the base.list file. For details about the base.list file content, see Default Content Mounted by the Ascend Docker Runtime.

    For details about how to create a configuration file, see Creating a Configuration File. The following uses the hostlog.list configuration file as an example (The file name extension must be .list.):

  • 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.