转载地址:https://bbs.huaweicloud.com/forum/thread-75723-1-1.html
作者:liaops
规格族:计算平衡增强型 c6e
实例规格:ecs.c6e.large
vCPU:2 vCPU
内存:4 GiB
处理器主频/睿频:2.5 GHz/3.2 GHz
处理器型号:Intel Xeon(Cascade Lake) Platinum 8269CY
操作系统:Ubuntu 18.04 64位
sudo apt-get update sudo DEBIAN_FRONTEND=noninteractive apt install -y \ vim \ wget \ curl \ xz-utils \ net-tools \ openssh-client \ git \ ntpdate \ tzdata \ tcl \ sudo \ bash-completion
sudo DEBIAN_FRONTEND=noninteractive apt install -y \ gcc \ g++ \ zlibc \ make \ libgmp-dev \ patch \ autoconf \ libtool \ automake \ libssl-dev \ flex
版本 >= 3.14.1
下载
wget https://github.com/Kitware/CMake/releases/download/v3.18.2/cmake-3.18.2-Linux-x86_64.sh
安装
sudo bash cmake-3.18.2-Linux-x86_64.sh --prefix=/usr/local sudo ln -s /usr/local/cmake-3.18.2-Linux-x86_64/bin/cmake /usr/local/bin/cmake
确认CMake安装成功
$ cmake -version cmake version 3.18.2 CMake suite maintained and supported by Kitware (kitware.com/cmake).
安装python3.7
sudo apt install software-properties-common sudo add-apt-repository ppa:deadsnakes/ppa sudo apt update sudo apt install python3.7 python3.7-dev
确认Python3.7安装成功
$ python3.7 -V Python 3.7.9
安装pip
python3.7 -m pip install pip echo "export PATH=$HOME/.local/bin:$PATH" > ~/.bashrc source ~/.bashrc
确认pip安装成功
$ pip -V pip 20.2.2 from /home/liaops/.local/lib/python3.7/site-packages/pip (python 3.7)
设置pip国内源
mkdir -pv ~/.pip echo "[global]" > ~/.pip/pip.conf echo "trusted-host=mirrors.aliyun.com" >> ~/.pip/pip.conf echo "index-url=http://mirrors.aliyun.com/pypi/simple/" >> ~/.pip/pip.conf
下载
git clone https://gitee.com/mindspore/mindspore.git cd mindspore git checkout v0.7.0-beta -b v0.7.0-beta
编译
bash build.sh -e cpu -t off -j1
编译完成时输出如下信息表示编译成功:
adding 'mindspore-0.7.0.dist-info/METADATA' adding 'mindspore-0.7.0.dist-info/WHEEL' adding 'mindspore-0.7.0.dist-info/top_level.txt' adding 'mindspore-0.7.0.dist-info/RECORD' removing build/bdist.linux-x86_64/wheel CPack: - package: /home/liaops/work/mindspore/build/mindspore/mindspore generated. success building mindspore project! ---------------- mindspore: build end ----------------
文件build/package/mindspore-0.7.0-cp37-cp37m-linux_x86_64.whl就是MindSpore安装包
pip install build/package/mindspore-0.7.0-cp37-cp37m-linux_x86_64.whl
注:
1.编译的瓶颈在于要下载很多第三方开源库,阿里云国内的服务器下载会非常慢,可以考虑香港的服务器。
2.多线程编译会报如下错误:
[ 23%] Built target engine-datasetops-mapop Scanning dependencies of target engine-opt [ 23%] Building CXX object mindspore/ccsrc/minddata/dataset/engine/opt/CMakeFiles/engine-opt.dir/pass.cc.o In file included from /home/liaops/mindspore/mindspore/ccsrc/minddata/dataset/engine/cache/cache_grpc_client.h:22:0, from /home/liaops/mindspore/mindspore/ccsrc/minddata/dataset/engine/cache/cache_client.h:28, from /home/liaops/mindspore/mindspore/ccsrc/minddata/dataset/engine/datasetops/cache_base_op.h:25, from /home/liaops/mindspore/mindspore/ccsrc/minddata/dataset/engine/datasetops/cache_op.h:23, from /home/liaops/mindspore/mindspore/ccsrc/minddata/dataset/engine/opt/pass.cc:21: /home/liaops/mindspore/mindspore/ccsrc/minddata/dataset/engine/cache/cache_common.h:40:10: fatal error: proto/cache_grpc.grpc.pb.h: No such file or directory #include "proto/cache_grpc.grpc.pb.h" ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated. mindspore/ccsrc/minddata/dataset/engine/opt/CMakeFiles/engine-opt.dir/build.make:81: recipe for target 'mindspore/ccsrc/minddata/dataset/engine/opt/CMakeFiles/engine-opt.dir/pass.cc.o' failed make[2]: *** [mindspore/ccsrc/minddata/dataset/engine/opt/CMakeFiles/engine-opt.dir/pass.cc.o] Error 1 CMakeFiles/Makefile2:2002: recipe for target 'mindspore/ccsrc/minddata/dataset/engine/opt/CMakeFiles/engine-opt.dir/all' failed make[1]: *** [mindspore/ccsrc/minddata/dataset/engine/opt/CMakeFiles/engine-opt.dir/all] Error 2 make[1]: *** Waiting for unfinished jobs....