335 Star 1.5K Fork 862

MindSpore / docs

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
mindspore_cpu_install_docker_en.md 5.63 KB
一键复制 编辑 原始数据 按行查看 历史
宦晓玲 提交于 2023-07-21 16:52 . modify the md links 1.8

Installing MindSpore in CPU by Docker

View Source On Gitee

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.

System Environment Information Confirmation

  • Ensure that a 64-bit Linux operating system with the x86 architecture is installed, where Ubuntu 18.04 is verified.
  • Ensure that Docker 18.03 or later versioin is installed.

Obtaining MindSpore Image

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.

Running MindSpore Image

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

Installation Verification

  • 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()"
  • 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 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.

1
https://gitee.com/mindspore/docs.git
git@gitee.com:mindspore/docs.git
mindspore
docs
docs
r1.8

搜索帮助

53164aa7 5694891 3bd8fe86 5694891