Skip to content

Latest commit

 

History

History
105 lines (70 loc) · 3.09 KB

install_with_docker_en.md

File metadata and controls

105 lines (70 loc) · 3.09 KB

MindQuantum Docker Installation GUide

Installing MindQuantum by Docker

This document describes how to use Docker to quickly install MindQuantum. First, you need to install MindSpore through Docker. The process is introduced on MindSpore's official website. This part will be repeated below.

Obtaining the 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}

In which, {tag} corresponds to the tag in the above table.

Running the 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

In which, {tag} corresponds to the tag in the above table.

MindSpore Installation Verification

  • If you are installing a container of the specified version x.y.z.

After entering the MindSpore container according to the above steps, to test whether Docker is working properly, please run the following Python code and check the output:

import numpy as np
import mindspore.context as context
import mindspore.operators as ops
from mindspore import Tensor

context.set_context(mode=context.PYNATIVE_MODE, device_target="CPU")

x = Tensor(np.ones([1,3,3,4]).astype(np.float32))
y = Tensor(np.ones([1,3,3,4]).astype(np.float32))
print(ops.add(x, y))

When the code runs successfully, it will output:

[[[ 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.]]]

At this point, you have successfully installed the MindSpore CPU version by Docker.

Installing MindQuantum Inside a Docker Container

  1. Enter the Docker container.

    docker exec -it {docker_container} /bin/bash

    In which, {docker_container} is the id or name of the docker container.

  2. Choose to install by pip or by compiling.

    Install by compiling:

    git clone https://gitee.com/mindspore/mindquantum.git
    cd ~/mindquantum
    python setup.py install --user

    Install by pip:

    pip install https://ms-release.obs.cn-north-4.myhuaweicloud.com/1.2.0-rc1/MindQuantum/ubuntu_x86/mindquantum-0.1.0-py3-none-any.whl --trusted-host ms-release.obs.cn-north-4.myhuaweicloud.com -i https://pypi.tuna.tsinghua.edu.cn/simple

MindQuantum Installation Verification

python -c 'import mindquantum'