[mindspire] mindspire1 is successfully used on Docker GPU version of 0.0

This article is on the host Ubuntu 16 Install Docker (NVIDIA Docker) on 04 and successfully perform mindspre1 0.0 GPU training;

1, Let's talk about the successful process first
[1]Mindspot official website GPU installation tutorial View specific process

  • The system requires ubuntu 18 04, but my ubuntu system version is 16.04. Because it is a multi person shared system, you can't upgrade the system directly. You can only install docker;
cat /proc/version     # Use this command to view the system version

[2] Install docker - docker is installed on my system
Here is a reference article: In Ubuntu 16 Article on installing docker on 04

docker version   # It is executed in the host machine to check whether the docker is successfully installed

 

[3] Install NVIDIA docker

  • You need to confirm that docker and NVIDIA driver are installed first
nvidia-smi   # Check that NVIDIA driver is installed
  • 1

  • Why do I need to install NVIDIA docker
nvidia-docker Is a can use GPU of docker,nvidia-docker Yes docker With a layer of packaging,
adopt nvidia-docker-plugin,Then call to docker Up,
Its ultimate realization is docker The startup command of carries some necessary parameters.
Therefore, when installing nvidia-docker Before, you still need to install docker of

docker Generally based on CPU And if so GPU If so, you need to install a unique hardware environment,
For example, it needs to be installed nvidia driver. 
therefore docker Containers are not directly supported Nvidia GPU. 
In order to solve this problem, the earliest solution is to reinstall all the components inside the container nvidia driver,
Then start by setting the corresponding equipment parameters container,However, this approach is fragile.
Because of the host driver The version of must exactly match the version in the container driver Version, which leads to docker image Unable to share,
It is likely that the inconsistency of local machines leads to the need for repeated operation of each machine, which is a great violation docker At the beginning of the design.

In order to make docker image It can be used conveniently Nvidia GPU,Thus produced nvidia-docker,
Made from it nvidia driver of image,This requires starting on the target machine container Make sure that the character device and driver files have been mounted.
nvidia-docker-plugin It's a docker plugin,Used to help us deploy easily container reach GPU Mixed environment.
Similar to a daemon, discover the host driver files and GPU Devices and mount these to docker In the request of the daemon.
To support docker GPU Use of.

1. Remove NVIDIA docker 1.0 from ubuntu system

sudo docker volume ls -q -f driver=nvidia-docker | xargs -r -I{} -n1 docker ps -q -a -f volume={} | xargs -r docker rm -f

sudo apt-get purge nvidia-docker

2. Install dependent packages

curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | \
  sudo apt-key add -
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | \
  sudo tee /etc/apt/sources.list.d/nvidia-docker.list
sudo apt-get update


3. Install nvidia-driver2 0

4. Verify that NVIDIA docker is installed successfully;
docker run --runtime=nvidia --rm nvidia/cuda:10.1-base nvidia-smi

[4] Pull mindspot GPU: 1.0.0 image Mindspot GPU image configured on Dokcer hub

[5] Note: here, you must use NVIDIA docker run command to generate a new container and directly enter Python into the compilation environment (python3.7.5 has been installed in mindspot GPU);

# The original docker command generates a new container (mindsore / mindsore GPU: 1.0.0 is the image name)
docker run -it mindspore/mindspore-gpu:1.0.0  /bin/bash

# Now the NVIDIA docker command generates a new container
nvidia-docker run -it mindspore/mindspore-gpu:1.0.0  /bin/bash
  • 1
  • 2
  • 3
  • 4
  • 5

Directly execute the code provided by mindspot official website to verify whether it is successful;

import numpy as np
from mindspore import Tensor
from mindspore.ops import functional as F
import mindspore.context as context

context.set_context(device_target="GPU")   #  Be sure to change the device to GPU here. The source code is Ascend
x = Tensor(np.ones([1,3,3,4]).astype(np.float32))
y = Tensor(np.ones([1,3,3,4]).astype(np.float32))
print(F.tensor_add(x, y))

 

If the following results occur, the installation verification is passed;

2, This is a trampled pit

[1] At first, I installed the graphics card driver directly on docker, because my host NVIDIA driver is version 418.39, but the recommended NVIDIA driver 450 is installed in the docker container. They seem to be incompatible, and various errors have been made in the middle;
Refer to:
[docker] install the graphics card driver, CUDA, CUDNN, etc. in docker

[2] It is known that there is nvidia/cuda image, but NVIDIA docker still needs to be installed;

[3] Join the qq group on mindspot's official website: 871543426 -- professionals can help answer questions;
When asked questions in the group, someone answered that there was a mindspot GPU image, which was very easy to use.

 

 

Tags: Docker gpu MindSpore

Posted by zamzon on Sat, 14 May 2022 10:38:01 +0300