Host Directories Mounted to Container
Prerequisites
- The driver software package has been installed on the host. For details, see Installing the Driver.
- You need to install Docker on the host. If NPU 20.0.X or NPU 20.1.X software packages are used for installation, the Docker version must be 18.03 or later.
- Run the following command to restart the Docker service:
systemctl daemon-reload systemctl restart docker
- Obtain the OS image. For example, if the container image is Ubuntu 18.04, run the following command:
docker pull ubuntu:18.04
If the obtained OS image version is incorrect, you are advised to obtain the correct OS image version from Ascend Hub.
- View the image:
docker images
Procedure
- Run the id HwHiAiUser command on the host to check the gid value of HwHiAiUser on the host. In the example shown in Figure 12-1, the gid value is 1001.If the NPU 20.1.X or later software package is used for installation and you use the --install-username=username --install-usergroup=usergroup parameters to specify a non-root user when installing the driver runfile, you need to use the same method to note down the gid of the non-root user. This gid is required when creating a non-root user in the container, ensure that the non-root users who start the related process in the host and container are in the same group.
- Create and start a Docker container on the host.
Mount the parameters listed in Table 12-2 to the container.
Table 12-2 Parameter descriptionParameter
Description
--device
Indicates the mapped device.
-v /usr/local/dcmi:/usr/local/dcmi
Mounts the .so dcmi file and the interface file directory /usr/local/dcmi on the host to the container. Change them as required.
-v /usr/local/sbin/npu-smi:/usr/local/sbin/npu-smi
If the NPU 20.0.0 software package is used for installation, mount the npu-smi tool /usr/local/sbin/npu-smi on the host to the container. Change the directory to the actual one.
-v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi
If NPU 20.0.0 or later or NPU 20.1.X or later software packages are used for installation, mount the npu-smi tool /usr/local/bin/npu-smi on the host to the container. Change the directory to the actual one.
-v /lib64:/lib64
Mounts the host directory /lib64 to a container.
NOTE:If the driver version is 1.73.5.2.B050 or later, you do not need to mount this directory to the container.
-v /var/log/npu/slog/container/container_name:/var/log/npu/slog
If software packages of NPU 20.0.0 or later or NPU 20.1.X are used for installation, mount the host log path /var/log/npu/slog/container/container_name to the container. Change it based on actual situation.
-v /var/log/npu/conf/slog/slog.conf:/var/log/npu/conf/slog/slog.conf
If software packages of NPU 20.0.0 or later or NPU 20.1.X are used for installation, mount the host log configuration file /var/log/npu/conf/slog/slog.conf to the container. Change it based on actual situation.
-v /usr/local/Ascend/driver/lib64/ :/usr/local/Ascend/driver/lib64/
Mounts the .so directory of Driver on the host to the container. Replace /usr/local/Ascend/driver/lib64/ as required.
-v /usr/local/Ascend/driver/tools/:/usr/local/Ascend/driver/tools/
If software packages of NPU 20.0.0 or later or NPU 20.1.X are used for installation, mount the host directory /usr/local/Ascend/driver/tools/ to the container. Change the directory based on the path where slogd is located.
-v /etc/ascend_install.info:/etc/ascend_install.info
Mount 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
Mount the host version information file /usr/local/Ascend/driver/version.info to the container. Modify the file according to your actual requirements.
After the container is started, run the following command to check the available Da Vinci devices in the Docker container:
ls /dev/ | grep davinci*
For details about the command execution, see Figure 12-2.
Where,
- davinci_manager is the character device node of the management module.
- davinci0 is the Da Vinci device name.
- Create a running user in the container to start related process. (If NPU 20.1.X or later software packages are used for installation, the running user is a non-root user, for example, HwHiAiUser.) If the running user is the root user, skip this step.
groupadd -g gid HwHiAiUser && useradd -g HwHiAiUser -d /home/HwHiAiUser -m HwHiAiUser && echo ok
Replace the gid value in the preceding command with that obtained in 1. If ok is returned, the creation is successful.
If a non-root user is created, ensure that the owner group of the non-root user is the same as that of the user who runs Driver. If they are different, add them to the Driver running user group.
- If you use the software package of NPU 20.2.X or later, you only need to perform If you use the software package of NPU 20.2.X, ... to set the environment variable. If the NPU 20.0.X or NPU 20.1.X software package is used for installation, you need to perform the following steps to start the slogd daemon process.
- Set the environment variable (an environment variable set in export mode takes effect only in the current window and takes effect immediately):
- If you use the software package of NPU 20.0.X or NPU 20.1.X, run the following command:
export LD_LIBRARY_PATH=/usr/local/Ascend/driver/lib64:/usr/local/Ascend/add-ons:$LD_LIBRARY_PATH
- If you use the software package of NPU 20.2.X or later, run the following command:
export LD_LIBRARY_PATH=/usr/local/Ascend/driver/lib64:$LD_LIBRARY_PATH
In the preceding command, /usr/local/Ascend is the default installation path. Replace it as required.
- If you use the software package of NPU 20.0.X or NPU 20.1.X, run the following command:
- Create log files and start the slogd process.
mkdir -p /usr/slog mkdir -p /var/log/npu/slog/slogd chown -Rf HwHiAiUser:HwHiAiUser /usr/slog chown -Rf HwHiAiUser:HwHiAiUser /var/log/npu/slog su HwHiAiUser --command "/usr/local/Ascend/driver/tools/slogd &"
- Check the slogd process and check if the Driver component is successfully installed:
ps -ef | grep -v grep | grep "tools/slogd"
If the following messages are returned, the process is started and the Driver component is installed successfully:
root@ascend-HP-ProDesk-600-G4-PCI-MT:/var/log/npu/conf/slog# ps -ef | grep -v grep | grep "tools/slogd" HwHiAiU+ 38 1 0 07:03 ? 00:00:00 /usr/local/Ascend/driver/tools/slogd
- Set the environment variable (an environment variable set in export mode takes effect only in the current window and takes effect immediately):