当前位置:网站首页>How to efficiently install the GPU version of mindspire
How to efficiently install the GPU version of mindspire
2022-07-24 03:30:00 【Shengsi mindspire】
MindSpore Of GPU Installation guide before version , Only the installation dependencies are clearly written , However, it does not specify the specific command to be executed during installation , Lack of practicality , It depends on the ability of the developer to complete the installation , As a result, developers will encounter some problems during the installation process Problems affecting installation efficiency . In the new version , The installation has been optimized , Provides automated scripts and step by step To help developers complete Ubuntu+GPU Version installation .
Based on automated scripts Ubuntu18.04 + GPU Version installation
The new installation guide gives automation as well step by step Installation mode , Include pip The way 、Conda The way and Source compilation method . If the environment is new , You can use automated scripts to install , If some software has been installed , You can also consider following the instructions later step by step To complete the installation .
Before installation , The user needs to execute nvidia-smi To check whether the driver is installed , Or whether the driver matches CUDA10.1/11.1. Drivers that are not installed or do not meet the minimum requirements , You need to install the driver according to the guide .
sudo apt-get update
sudo apt-get install ubuntu-drivers-common
sudo ubuntu-drivers autoinstall
Next, just execute the automated script , Suppose we need to install Python 3.9 And use pip complete 1.6.1 Of MindSpore Version installed , Then you can run the following script :
wget https://gitee.com/mindspore/mindspore/raw/master/scripts/install/ubuntu-gpu-pip.sh
# install MindSpore 1.6.1,Python 3.9 and CUDA 11.1.
PYTHON_VERSION=3.9 MINDSPORE_VERSION=1.6.1 bash -i ./ubuntu-gpu-pip.sh
If your network condition is better , So in 10-15 minute You can finish the installation , The automation script will also do it automatically at the end of execution run check Check and run simple code validation , The final result you see should be like this :
MindSpore version: 1.6.1
The result of multiplication calculation is correct, MindSpore has been installed successfully!
[[[[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.]]]]
Automated script interpretation
With pip Mode install script For example , Let's look at the implementation of the script , Understanding scripts can help you better modify and expand scripts . The whole script can be divided into four parts : 1. Parameter setting and inspection ; 2. The three parties rely on installation ; 3. CUDA And CUDNN install ; 4. MindSpore Installation and verification ;
Three of them rely on installation and MindSpore Relatively simple , The following focuses on the parameter setting check and CUDA install , It will be helpful for understanding the use of scripts and extending functions .
Parameters that affect the operation of the script
The first paragraph of the script provides three adjustable parameters ,Python edition (3.7,3.8,3.9)、MindSpore Version of (>=1.6.0) as well as Cuda Version of (10.1,11.1), The user controls the environment to be configured through environment variables , Such as
PYTHON_VERSION=3.9 MINDSPORE_VERSION=1.6.1 CUDA_VERSION=10.1 bash -i ./ubuntu-gpu-pip.shCan finish Python3.9、Cuda10.1 as well as MindSpore 1.6.1 Version installation of .
PYTHON_VERSION=${PYTHON_VERSION:-3.7}
MINDSPORE_VERSION=${MINDSPORE_VERSION:EMPTY}
CUDA_VERSION=${CUDA_VERSION:-11.1}
Here the script uses points shell Tips ,PYTHON_VERSION=${PYTHON_VERSION:-3.7} finger PYTHON_VERSION Default is 3.7, But if the user sets a new value before the script executes , Then use the new value .
CUDA and CUDDN Installation
Nvidia In fact, it provides cuda Domestic image source of relevant software packages , Based on image source , You can quickly download cuda Of run package , Use silence to complete cuda Installation . Then use the same way apt-get Mode of installation cudnn and libcudnn-dev. If you want to install other small versions , Can open “https://developer.download.nvidia.cn/compute/cuda/repos/ubuntu1804/x86_64/” and “https://developer.download.nvidia.cn/compute/machine-learning/repos/ubuntu1804/x86_64/” Address to find the small version number, and then execute the script to complete the installation after replacement .
# Download and install Cuda
echo "installing CUDA and cuDNN"
cd /tmp
declare -A cuda_url_map=()
cuda_url_map["10.1"]=https://developer.download.nvidia.cn/compute/cuda/10.1/Prod/local_installers/cuda_10.1.243_418.87.00_linux.run
cuda_url_map["11.1"]=https://developer.download.nvidia.cn/compute/cuda/11.1.1/local_installers/cuda_11.1.1_455.32.00_linux.run
cuda_url=${cuda_url_map[$CUDA_VERSION]}
wget $cuda_url
sudo sh ${cuda_url##*/} --silent --toolkit
cd -
# add to cudnn/libcuda Mirror source for
sudo apt-key adv --fetch-keys https://developer.download.nvidia.cn/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
sudo add-apt-repository "deb https://developer.download.nvidia.cn/compute/cuda/repos/ubuntu1804/x86_64/ /"
sudo add-apt-repository "deb https://developer.download.nvidia.cn/compute/machine-learning/repos/ubuntu1804/x86_64/ /"
sudo apt-get update
declare -A cudnn_name_map=()
cudnn_name_map["10.1"]="libcudnn7=7.6.5.32-1+cuda10.1 libcudnn7-dev=7.6.5.32-1+cuda10.1"
cudnn_name_map["11.1"]="libcudnn8=8.0.4.30-1+cuda11.1 libcudnn8-dev=8.0.4.30-1+cuda11.1"
sudo apt-get install --no-install-recommends ${cudnn_name_map[$CUDA_VERSION]} -y
# add to cuda To PATH and LD_LIBRARY_PATH in
set +e && source ~/.bashrc
set -e
add_env PATH /usr/local/cuda/bin
add_env LD_LIBRARY_PATH /usr/local/cuda/lib64
add_env LD_LIBRARY_PATH /usr/lib/x86_64-linux-gnu
set +e && source ~/.bashrc
Shortcomings of automated scripts
Automated scripts are designed , Considering the cost of test validation , Did not Ubuntu20.04 and WSL Add to the scope of acceptance , This causes these two types of users to report errors when executing , The corresponding problem has been transformed into issue(Ubuntu 20.04 Support , WSL Support ).
How to expand script completion Ubuntu20.04 as well as WSL Automatic installation on
Expand support Ubuntu 20.04
If we look at the script explanation again cuda Part of the installation , You can see “repos/ubuntu1804” If it is replaced by “repos/ubuntu2004”, You can support Ubuntu20.04 了 . So we need to extract one from the script Ubuntu Version variables , adopt Linux Command to get Ubuntu Version number , Then fill in the download address . The specific modifications are as follows , adopt lsb_release -a | grep Release Get the string containing the version, such as "Release: 20.04", Then based on Linux Magic function of string ${release_info//[!0-9]/} Extract a number from a string 2004. Here is an additional judgment , because Ubuntu 20.04 I won't support it Cuda 10.1. In the later installation part, just change the hard coded version number to the reference variable .
release_info=$(lsb_release -a | grep Release)
UBUNTU_VERSION=${release_info//[!0-9]/}
[[ "$UBUNTU_VERSION" == "2004" && "$CUDA_VERSION" == "10.1" ]] && echo "CUDA 10.1 is not supported on Ubuntu 20.04" && exit 1
#...
sudo apt-key adv --fetch-keys https://developer.download.nvidia.cn/compute/cuda/repos/ubuntu${UBUNTU_VERSION}/x86_64/7fa2af80.pub
sudo add-apt-repository "deb https://developer.download.nvidia.cn/compute/cuda/repos/ubuntu${UBUNTU_VERSION}/x86_64/ /"
sudo add-apt-repository "deb https://developer.download.nvidia.cn/compute/machine-learning/repos/ubuntu${UBUNTU_VERSION}/x86_64/ /"
sudo
solve WSL The problem of automatic installation on
The original script is WSL You will encounter an error when executing the following script on .
driver_version=$(modinfo nvidia | grep ^version | awk '{printf $2}')
if [[ $driver_version < ${minimum_driver_version_map[$CUDA_VERSION]} ]]; then
echo "CUDA $CUDA_VERSION minimum required driver version is ${minimum_driver_version_map[$CUDA_VERSION]}, \
but current nvidia driver version is $driver_version, please upgrade your driver manually."
exit 1
fi
The error message is as follows :
[email protected]:~/jenkins$ MINDSPORE_VERSION=1.6.1 bash -i ubuntu-gpu-pip.sh
modinfo: ERROR: Module alias nvidia not found.
CUDA 11.1 minimum required driver version is 450.80.02, but current nvidia driver version is , please upgrade your driver manually.
The reason for the error is the command to get the drive information modinfo nvidia stay WSL The executive meeting will report directly modinfo: ERROR: Module alias nvidia not found. error . The solution is to use nvidia-smi --query-gpu=driver_version --format=csv,noheader --id=0 Get Nvidia Driven information . If the driver is not installed , Command execution returns null , The following check logic can also work normally , Prompt to install the upgraded driver version .
driver_version=$(nvidia-smi --query-gpu=driver_version --format=csv,noheader --id=0)
if [[ $driver_version < ${minimum_driver_version_map[$CUDA_VERSION]} ]]; then
echo "CUDA $CUDA_VERSION minimum required driver version is ${minimum_driver_version_map[$CUDA_VERSION]}, \
but current nvidia driver version is $driver_version, please upgrade your driver manually."
exit 1
fi
Relevant scripts are in Huawei cloud and WSL Of Ubuntu18.04/20.04 The verification is completed on , It should work , Modification sent Pull Request.
summary
At present MindSpore Of Master In the branch , except GPU Automatic installation of version , For shengteng and CPU Etc , It also provides automated scripts and simplified installation guide , I believe these scripts and guidelines can continue to improve MindSpore Installation experience under multiple platforms .
边栏推荐
- Secondary development of ArcGIS JS API -- loading national sky map
- Istio architecture extension mechanism
- STL set container
- It's solved with a cry
- Keras deep learning practice (15) -- realize Yolo target detection from scratch
- Jump statements break and continue
- JS 数组 isAarray() typeof
- Huawei then responded to the rumor of "cleaning up employees over the age of 34". How can programmers cope with the "35 year old crisis"?
- Hcip day 9 notes (OSPF routing feedback, routing policy, and Configuration Guide)
- Insist on accompanying study
猜你喜欢

什么是IMU?

轮播图van-swipe的报错:cannot read a properties of null(reading width)

Cannot resolve symbol 'override' of idea clone‘
![Embedded system transplantation [5] - Cross compilation tool chain](/img/2a/eadaaafe794aa9b3106441fa50ffc7.png)
Embedded system transplantation [5] - Cross compilation tool chain

Bingbing learning notes: basic operation of vim tool

Leetcode-382. random nodes of linked list

Appendtofile append failed

Gpushare.com | 如何使用TensorBoardX可视化工具?

How emqx 5.0 under the new architecture of mria + rlog realizes 100million mqtt connections

Programmers may still be programmers, and coders may only be coders
随机推荐
Network parameter management
Keras deep learning practice (15) -- realize Yolo target detection from scratch
Huawei then responded to the rumor of "cleaning up employees over the age of 34". How can programmers cope with the "35 year old crisis"?
Do you know how to do interface testing well?
如何在 pyqt 中实现桌面歌词
JS 數組 isAarray() typeof
Do the right thing, do it right
水题: 接雨水
Android开发——Kotlin语法之Lambda表达式
Basic syntax of MySQL DDL and DML and DQL
Embedded system transplantation [5] - Cross compilation tool chain
[interpolation expression of applet, rendering judgment, binding events and sharing]
uva1445
Conteneur STL set
IO流分类整理
CVE-2022-29464 WSO2文件上传漏洞
Basic syntax of MySQL DDL and DML and DQL
Introduction to pytorch ecology
OSPF comprehensive experimental configuration
C语言经典练习题(2)——“冒泡排序(Bubble Sort)“