GPU云服务器mindspore部署测试
1、准备Ubuntu18.04的ECS
2、制作私有镜像Ubuntu18.04
ECS虚拟机关机,生成私有镜像
3、使用私有镜像Ubuntu18.04开通GPU云服务器
登录ECS
4、mindspore环境准备
4.1 安装libsndfile包
sudo apt-get install libsndfile*
4.2 root下执行:dpkg-reconfigure dash
在界面中选择no
4.3创建use1
#mkdir -p /home/user1
#useradd user1
#passwd user1
#chown -R user1.user1 /home/user1/
#cp .bashrc /home/user1/.bashrc
#chown user1.user1 /home/user1/.bashrc
4.4 user1用户安装Anaconda3
#wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-5.3.1-Linux-x86_64.sh
#cp Anaconda3-5.3.1-Linux-x86_64.sh /home/user1/Anaconda3-5.3.1-Linux-x86_64.sh
# chown user1.user1 /home/user1/Anaconda3-5.3.1-Linux-x86_64.sh
切换用户安装Anaconda3
su - user1
$ bash Anaconda3-5.3.1-Linux-x86_64.sh
回车
按提示输入yes
提示信息“Do you wish to proceed with the installation of Microsoft VSCode? [yes|no]”,输入no;
4.5创建user1用户的python环境
vim ~/.bashrc
export PATH="/home/user1/anaconda3/bin:$PATH"
source ~/.bashrc
执行python命令确认python已安装
执行exit()退出python
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes
执行conda create -n seb python=3.7.5
切换到环境seb
source activate seb
4.6 安装cuda10.1
wget https://developer.nvidia.com/compute/cuda/10.1/Prod/local_installers/cuda_10.1.105_418.39_linux.run
#sudo sh cuda_10.1.105_418.39_linux.run
安装完成后检查确认
find / -type f -name libcuda.so.* -exec dirname {} \; 2>/dev/null
find / -type f -name libssl.so.* -exec dirname {} \; 2>/dev/null
如回显信息中有CUDA的版本信息证明CUDA安装成功
cd /usr/local/cuda-10.1/samples/1_Utilities/deviceQuery
make
./deviceQuery
user1执行
cd /usr/local/cuda-10.1/samples/1_Utilities/deviceQuery
./deviceQuery
user1用户执行
vim ~/.bashrc
export PATH=/usr/local/cuda-10.1/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-10.1/lib64:$LD_LIBRARY_PATH
source ~/.bashrc
4.7安装cudnn
wget https://developer.nvidia.com/compute/machine-learning/cudnn/secure/v7.6.0.64/prod/10.1_20190516/cudnn-10.1-linux-x64-v7.6.0.64.tgz
#tar -zxvf cudnn-10.1-linux-x64-v7.6.4.38.tgz
#cd cuda
#cp ./include/* /usr/local/cuda/include
4.8安装GMP
#sudo apt-get install m4
#wget https://gmplib.org/download/gmp/gmp-6.1.2.tar.bz2
#mkdir -p '/home/shims/install/gmp/share/info'
#tar -jxvf gmp-6.1.2.tar.bz2
#cd gmp-6.1.2
#./configure --prefix=/home/shims/install/gmp
#make
#make check
#make install
user1用户执行
vim ~/.bashrc
#gmp-4.3.2
export LD_LIBRARY_PATH=/home/shims/install/gmp4.3.2/lib:$LD_LIBRARY_PATH
source ~/.bashrc
5、mindspore安装
#pip install --upgrade pip
#wget https://ms-release.obs.cn-north-4.myhuaweicloud.com/1.0.0/MindSpore/gpu/ubuntu_x86/cuda-10.1/mindspore_gpu-1.0.0-cp37-cp37m-linux_x86_64.whl
#cp mindspore_gpu-1.0.0-cp37-cp37m-linux_x86_64.whl /home/user1/mindspore_gpu-1.0.0-cp37-cp37m-linux_x86_64.whl
# chown user1.user1 /home/user1/mindspore_gpu-1.0.0-cp37-cp37m-linux_x86_64.whl
user1用户执行
source ~/.bashrc
激活seb环境
source activate seb
安装mindspore
pip install --upgrade scipy==1.3.3 -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install --upgrade sympy==1.7.1 -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install mindspore_gpu-1.0.0-cp37-cp37m-linux_x86_64.whl
如报超时,加延迟检测时间参数:
pip --default-timeout=1000 install mindspore_gpu-1.0.0-cp37-cp37m-linux_x86_64.whl
pip show mindspore-gpu
6、mindspore测试
vim test.py
内容如下
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")
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))
执行python test.py查看结果
- 点赞
- 收藏
- 关注作者
评论(0)