Deploying a Container Image.
When the host environment is CentOS, the SELinux security module of CentOS is enabled by default. As a result, the local directory mounted to the container does not have the execute permission. Therefore, you need to run the su -c "setenforce 0" command to temporarily disable the SELinux. After related services are complete, run the su -c "setenforce 1" command to enable SELinux again.
- Run the following command to run a container based on the new image:
1docker run -itd -e ASCEND_VISIBLE_DEVICES=xxx --pids-limit 409600 image-name:tag /bin/bash
Example:
1docker run -itd -e ASCEND_VISIBLE_DEVICES=0 ascend-cann:8.0.0-ubuntu /bin/bash
Table 1 Parameter description Parameter
Description
ASCEND_VISIBLE_DEVICES=xxx
Use the ASCEND_VISIBLE_DEVICES environment variable to specify the NPUs mounted to the container (you can run the ls /dev/ | grep davinci* command to query the NPUs of the host). The device sequence number is used to specify the device. You can specify a single device or a range of devices, and the devices can be used together. See the following examples:
- 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 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 ASCEND_VISIBLE_DEVICES=0,1,2,4.
--pids-limit 409600
If the host OS is CentOS or BC-Linux, the maximum number of threads in Docker is 4092, which cannot meet the training requirements. In this case, this parameter needs to be added to configure the maximum number of Docker threads in CentOS/BC-Linux during container startup.
image-name:tag
Image name and tag. Enter the built CANN container image (for example, ascend-cann:cann-openeuler).
If the container ID (1dc80f32c263 in this example) is displayed, the container is started.
Run the following command to access the container:
1docker exec -it <CONTAINER ID> /bin/bash
Example command:
1docker exec -it 1dc80f32c263 /bin/bash
If the following information is displayed, the container is successfully accessed:
1uername@1dc80f32c263:~$
If you have created a model file directory on the host (for model training in the container), you can mount the model directory (for example, /data/model ) when starting the container. A command example is as follows:
1docker run -itd -e ASCEND_VISIBLE_DEVICES=0 -v /data/model:/data/model ascend-tensorflow:8.0.0-ubuntu18.04-arm64 /bin/bash
- After the container is started, run the following command to check the available Da Vinci devices in the Docker container:
1ls /dev/ | grep davinci*
The command output is as follows:

In the preceding information:
- davinci_manager is the character device node of the management module.
- davinci0 is the Da Vinci device name.
- Configure environment variables. Replace it with the actual installation path of set_env.sh.
1source <path>/set_env.sh
Replace <path> with the actual installation path of the CANN package.