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 by Docker in a Linux system with a CPU environment.
The Docker image of MindSpore is hosted on Huawei SWR.
The current support for the containerization build option is as follows:
Hardware | Docker Image Hub | Label | Note |
---|---|---|---|
CPU | mindspore/mindspore-cpu |
x.y.z |
A production environment with the MindSpore x.y.z CPU version pre-installed. |
devel |
Provide a development environment to build MindSpore from the source (CPU backend). For installation details, please refer to https://www.mindspore.cn/install/en. |
||
runtime |
Provide runtime environment, MindSpore binary package (CPU backend) is not installed. |
x.y.z
corresponds to the MindSpore version number. For example, when MindSpore version 1.1.0 is installed,x.y.z
should be written as 1.1.0.
For the CPU
backend, you can directly use the following command to obtain the latest stable image:
docker pull swr.cn-south-1.myhuaweicloud.com/mindspore/mindspore-cpu:{tag}
of which,
{tag}
corresponds to the label in the above table.Execute the following command to start the Docker container instance:
docker run -it swr.cn-south-1.myhuaweicloud.com/mindspore/mindspore-cpu:{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 --network host swr.cn-south-1.myhuaweicloud.com/mindspore/mindspore-cpu:{tag} /bin/bash
If you are installing the container of the specified version x.y.z
.
After entering the MindSpore container according to the above steps, to test whether the Docker is working properly, please run the following Python code and check the output:
i:
python -c "import mindspore;mindspore.run_check()"
MindSpore version: __version__
The result of multiplication calculation is correct, MindSpore has been installed successfully!
So far, it means MindSpore CPU has been installed by Docker successfully.
ii:
import numpy as np
import mindspore as ms
import mindspore.ops as ops
ms.set_context(mode=ms.PYNATIVE_MODE, device_target="CPU")
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))
When the code is successfully run, 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 CPU has been installed by Docker successfully.
If you need to verify the MindInsight installation:
Enter mindinsight start --port 8080
, and if it prompts that the startup status is successful, it means MindInsight has been installed successfully.
If you install a container with the label of runtime
, you need to install MindSpore yourself.
Go to MindSpore Installation Guide Page, choose the CPU hardware platform, Linux-x86_64 operating system and pip installation method to get the installation guide. Refer to the installation guide after running the container and install the MindSpore CPU version by pip, and verify it.
If you install a container with the label of devel
, you need to compile and install MindSpore yourself.
Go to MindSpore Installation Guide Page, and choose the CPU hardware platform, Linux-x86_64 operating system and pip installation method to get the installation guide. After running the container, download the MindSpore code repository and refer to the installation guide, install the MindSpore CPU version through source code compilation, and verify it.
If you want to know more about the MindSpore Docker image building process, please check docker repo for details.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。