Installing MindSpore in Ascend 910 by Docker
Docker is an open source application container engine, and developers can package their applications and dependencies into a lightweight, portable container. By using Docker, MindSpore can be rapidly deployed and separated from the system environment.
This document describes how to quickly install MindSpore in a Linux system with an Ascend 910 environment by Docker.
The Docker image of MindSpore is hosted on Huawei SWR.
The current support for containerized build options is as follows:
Hardware |
Docker Image Hub |
Label |
Note |
Ascend |
mindspore/mindspore-ascend |
x.y.z |
The production environment of MindSpore Ascend x.y.z together with the corresponding version of Ascend Data Center Solution. |
x.y.z
corresponds to the MindSpore version number. For example, when MindSpore version 1.8.1 is installed, x.y.z
should be written as 1.8.1.
System Environment Information Confirmation
Installing Ascend AI processor software package
Ascend software package provides two distributions, commercial edition and community edition:
The default installation path of the installation package is /usr/local/Ascend
. Ensure that the current user has the right to access the installation path of Ascend AI processor software package, If not, the root user needs to add the current user to the user group where /usr/local/Ascend
is located.
Obtaining MindSpore Image
For the Ascend
backend, you can directly use the following command to obtain the latest stable image:
docker pull swr.cn-south-1.myhuaweicloud.com/mindspore/mindspore-ascend:{tag}
of which,
{tag}
corresponds to the label in the above table.
Running MindSpore Image
Execute the following command to start the Docker container instance:
docker run -it -u root --ipc=host \
--device=/dev/davinci0 \
--device=/dev/davinci1 \
--device=/dev/davinci2 \
--device=/dev/davinci3 \
--device=/dev/davinci4 \
--device=/dev/davinci5 \
--device=/dev/davinci6 \
--device=/dev/davinci7 \
--device=/dev/davinci_manager \
--device=/dev/devmm_svm \
--device=/dev/hisi_hdc \
-v /usr/local/Ascend/driver:/usr/local/Ascend/driver \
-v /var/log/npu/:/usr/slog \
swr.cn-south-1.myhuaweicloud.com/mindspore/mindspore-ascend:{tag} \
/bin/bash
of which,
{tag}
corresponds to the label in the above table.
If you want to use MindInsight, you need to set the --network
parameter to "host" mode, for example:
docker run -it -u root --ipc=host \
--network host \
--device=/dev/davinci0 \
--device=/dev/davinci1 \
--device=/dev/davinci2 \
--device=/dev/davinci3 \
--device=/dev/davinci4 \
--device=/dev/davinci5 \
--device=/dev/davinci6 \
--device=/dev/davinci7 \
--device=/dev/davinci_manager \
--device=/dev/devmm_svm \
--device=/dev/hisi_hdc \
-v /usr/local/Ascend/driver:/usr/local/Ascend/driver \
-v /var/log/npu/:/usr/slog \
swr.cn-south-1.myhuaweicloud.com/mindspore/mindspore-ascend:{tag} \
/bin/bash
Installation Verification
After entering the MindSpore container according to the above steps, to test whether the Docker container is working properly, please run the following Python code and check the output:
i:
python -c "import mindspore;mindspore.run_check()"
The outputs should be the same as:
MindSpore version: __version__
The result of multiplication calculation is correct, MindSpore has been installed successfully!
So far, it means MindSpore Ascend 910 has been installed by Docker successfully.
ii:
import numpy as np
import mindspore as ms
import mindspore.ops as ops
ms.set_context(device_target="Ascend")
x = ms.Tensor(np.ones([1,3,3,4]).astype(np.float32))
y = ms.Tensor(np.ones([1,3,3,4]).astype(np.float32))
print(ops.add(x, y))
The outputs should be the same as:
[[[[2. 2. 2. 2.]
[2. 2. 2. 2.]
[2. 2. 2. 2.]]
[[2. 2. 2. 2.]
[2. 2. 2. 2.]
[2. 2. 2. 2.]]
[[2. 2. 2. 2.]
[2. 2. 2. 2.]
[2. 2. 2. 2.]]]]
So far, it means MindSpore Ascend 910 has been installed by Docker successfully.
If you need to verify the MindInsight installation:
Enter mindinsight start --port 8080
, if it prompts that the startup status is successful, it means MindInsight has been installed successfully.
Version Update
When you need to update the MindSpore version:
- update corresponding Ascend AI processor software package according to MindSpore package version of which you wish to update.
- directly use the following command to obtain the latest stable image:
docker pull swr.cn-south-1.myhuaweicloud.com/mindspore/mindspore-ascend:{tag}
of which,
{tag}
corresponds to the label in the above table.