记一次失败记录: MindSpore1.3.0 GPU 源码安装 —— Ubuntu18.04系统 (最终安装结果为失败)

官网地址:

https://www.mindspore.cn/install

 

 

系统:Ubuntu18.04

硬件:

i7-9700k CPU

2060super nvidia显卡

 

 

 

由于考虑到mindspore版本更新,依赖环境的变化,因此将mindspore依赖的环境安装到自建文件夹下,

给出下面操作中环境的安装文件夹:

/home/devilmaycry/anaconda3/mindspore_envs
这个路径可以按照个人情况进行设置的,只要下面均保持一致即可。

 

 

下文中修改 .bashrc  是指打开.bashrc :

vim ~/.bashrc

 

 

本文假设系统中已经为GPU显卡安装好驱动程序了,因此本文不介绍驱动的安装。

 

 

(请注意:下面的安装建议按照步骤来进行)

 

 

 

================================================================

 

 

 

 

1.  安装CUDA11.1.0 和 cuDNN 8.0.X版本:

cuda安装

创建cuda的安装目录:

mkdir cuda11.1

 

查看所创建路径:

/home/devilmaycry/anaconda3/mindspore_envs/cuda11.1

 

 

下载并安装:

wget https://developer.download.nvidia.com/compute/cuda/11.1.0/local_installers/cuda_11.1.0_455.23.05_linux.run

sh ./cuda_11.1.0_455.23.05_linux.run --toolkit  --toolkitpath=/home/devilmaycry/anaconda3/mindspore_envs/cuda11.1  --silent

 

 

 

2.   cuDnn安装:

下载地址:

https://developer.nvidia.com/compute/machine-learning/cudnn/secure/8.0.5/11.1_20201106/cudnn-11.1-linux-x64-v8.0.5.39.tgz

 

 解压文件:

              tar -zxvf cudnn-11.1-linux-x64-v8.0.5.39.tgz

 

 

拷贝解压后的文件到cuda安装目录内:

 cp cuda/include/*  /home/devilmaycry/anaconda3/mindspore_envs/cuda11.1/include

 cp cuda/lib64/*  /home/devilmaycry/anaconda3/mindspore_envs/cuda11.1/lib64

 

 

 

 

配置环境变量:

修改  .bashrc  文件

# cuda&cudnn
export LD_LIBRARY_PATH=/home/devilmaycry/anaconda3/mindspore_envs/cuda11.1/lib64:$LD_LIBRARY_PATH
export PATH=/home/devilmaycry/anaconda3/mindspore_envs/cuda11.1/bin:$PATH

 



 

 

================================================================

 

 

 

 

 GCC的安装:

 

 

下载gcc 7.3.0版本安装包,执行以下命令:

              wget http://ftp.gnu.org/gnu/gcc/gcc-7.3.0/gcc-7.3.0.tar.gz

 

执行tar -xzf gcc-7.3.0.tar.gz解压源码包。

 

执行cd gcc-7.3.0,进入到源码包目录。

 

继续下面操作前清空系统内的环境变量:

export LIBRARY_PATH=
export LD_LIBRARY_PATH=
export C_INCLUDE_PATH=
export CPLUS_INCLUDE_PATH=

 

 

 

 

运行以下命令,进行安装前的配置。

安装依赖环境:

./contrib/download_prerequisites

 

 

配置环境:

./configure --prefix=/home/devilmaycry/anaconda3/mindspore_envs/gcc_7.3.0 --enable-bootstrap -enable-threads=posix --enable-checking=release --enable-languages=c,c++ --disable-multilib

 

 

 

 

 

 编译安装:

make -j8 && make install

 

 

 

 

 

 

 配置系统环境:  修改  .bashrc  文件,添加内容:

# gcc
export PATH=/home/devilmaycry/anaconda3/mindspore_envs/gcc_7.3.0/bin:$PATH

###export LIBRARY_PATH=/home/devilmaycry/anaconda3/mindspore_envs/gcc_7.3.0/share:$LIBRARY_PATH
export LD_LIBRARY_PATH=/home/devilmaycry/anaconda3/mindspore_envs/gcc_7.3.0/lib64:$LD_LIBRARY_PATH

export C_INCLUDE_PATH=/home/devilmaycry/anaconda3/mindspore_envs/gcc_7.3.0/include:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=$C_INCLUDE_PATH:$CPLUS_INCLUDE_PATH

 

 

 

 

 

 

 

=========================================================

 

 

 

 

m4  下载安装:

下载:

wget   http://ftp.gnu.org/gnu/m4/m4-1.4.16.tar.bz2

 

解压:

               tar -jxvf m4-1.4.16.tar.bz2

 

 

 

修改m4_1.4.16下源文件中代码:(https://blog.csdn.net/weixin_34168880/article/details/91842744

vi lib/stdio.in.h

查找字段:gets is a security hole

注释
将_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead"); 字段和他之前的注释 /* 一块注释掉,如下

/* It is very rare that the developer ever has full control of stdin,
   so any use of gets warrants an unconditional warning.  Assume it is
   always declared, since it is required by C89.
#undef gets
_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead"); */

 

再添加如下内容:

    #if defined(__GLIBC__) && !defined(__UCLIBC__) && !__GLIBC_PREREQ(2, 16)
     
    _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
     
    #endif

 

 

配置:

./configure --prefix=/home/devilmaycry/anaconda3/mindspore_envs/m4_1.4.16/

 

 

编译安装

make && make install

 

 

 

配置系统环境变量:

修改 .bashrc  文件

export PATH=/home/devilmaycry/anaconda3/mindspore_envs/m4_1.4.16/bin:$PATH

 

 

 

 

说明: 其中,/home/devilmaycry/anaconda3/mindspore_envs/m4_1.4.16   路径为我们刚才编译源码配置安装路径的地址。

 

 

 

 ==============================================================

 

 

需要注意:安装好m4后需要执行命令  soure  ~/.bashrc   ,然后才可以继续安装gmp。

 

安装gmp 6.1.2

 下载gmp 6.1.2源码包:

            wget https://gmplib.org/download/gmp/gmp-6.1.2.tar.xz

 

 

解压到当前文件夹:

           tar -xvf  gmp-6.1.2.tar.xz

 

 

 

 配置:

 ./configure --prefix=/home/devilmaycry/anaconda3/mindspore_envs/gmp_6.1.2/ --enable-cxx

 

 编译安装:

make && make install

 

 

 

 

配置系统环境变量:  修改 .bashrc 文件

# gmp
export LIBRARY_PATH=/home/devilmaycry/anaconda3/mindspore_envs/gmp_6.1.2/lib:$LIBRARY_PATH
export LD_LIBRARY_PATH=/home/devilmaycry/anaconda3/mindspore_envs/gmp_6.1.2/lib:$LD_LIBRARY_PATH

export C_INCLUDE_PATH=/home/devilmaycry/anaconda3/mindspore_envs/gmp_6.1.2/include:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=$C_INCLUDE_PATH:$CPLUS_INCLUDE_PATH

 



 

 

测试 gmp 是否安装并配置成功:(声明:测试部分内容源于:https://blog.csdn.net/just_h/article/details/82667787

代码:

# test.cpp 文件

#include <gmpxx.h>
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
        mpz_t a,b,c;
        mpz_init(a);
        mpz_init(b);
        mpz_init(c);
        gmp_scanf("%Zd%Zd",a,b);
        mpz_add(c,a,b);
        gmp_printf("c= %Zd\n",c);
        return 0;
}

编译:

g++ test.cpp -o test -lgmp

 

运行:

 

 

 

 

 

 

 

 

 openssl 的安装:

下载地址:

https://www.openssl.org/source/openssl-1.1.1k.tar.gz

 

解压:

tar -zxvf openssl-1.1.1k

 

 配置:

./config --prefix=/home/devilmaycry/anaconda3/mindspore_envs/openssl_1.1.1

 

 

编译并安装:

make -j8&& make install

 

配置系统环境:修改 .bashrc 文件,  添加内容:

# openssl
export OPENSSL_ROOT_DIR=/home/devilmaycry/anaconda3/mindspore_envs/openssl_1.1.1

export OPENSSL_INCLUDE_DIR=/home/devilmaycry/anaconda3/mindspore_envs/openssl_1.1.1/include
export OPENSSL_CRYPTO_LIBRARY=/home/devilmaycry/anaconda3/mindspore_envs/openssl_1.1.1/lib

 

 

 重新载入  .bashrc 文件:

source ~/.bashrc

 

 

 

 

 

 

 

cmake 安装:

下载文件:

wget    https://github.com/Kitware/CMake/releases/download/v3.21.0/cmake-3.21.0.tar.gz

 

 

解压:

tar -zxvf cmake-3.21.0.tar.gz

 

 

配置:

./configure --prefix=/home/devilmaycry/anaconda3/mindspore_envs/cmake_3.21.0

 

 

 

编译并安装:

make -j8&& make install

 

 

 

配置系统环境:

 修改  ~/.bashrc 文件,添加内容:

# make
export PATH=/home/devilmaycry/anaconda3/mindspore_envs/cmake_3.21.0/bin:$PATH

 

 

 

 

 重新载入  .bashrc 文件:

source ~/.bashrc

 

 

 

 

 

 

 

patch 的安装:

下载文件:

wget  https://ftp.gnu.org/gnu/patch/patch-2.7.6.tar.gz

 

 

解压:

tar -zxvf patch-2.7.6.tar.gz

 

 

配置:

./configure --prefix=/home/devilmaycry/anaconda3/mindspore_envs/patch_2.7.6

 

 

 

编译并安装:

make -j8&& make install

 

 

 

配置系统环境:

 修改  ~/.bashrc 文件,添加内容:

# patch
export PATH=/home/devilmaycry/anaconda3/mindspore_envs/patch_2.7.6/bin:$PATH

 

 

 

 

 重新载入  .bashrc 文件:

source ~/.bashrc

 

 

 

 

 

 

 

 

 

 安装Autoconf

下载文件:

wget https://ftp.gnu.org/gnu/autoconf/autoconf-2.71.tar.gz

 

 

 解压:

 tar -zxvf autoconf-2.71.tar.gz

 

 配置:

./configure --prefix=/home/devilmaycry/anaconda3/mindspore_envs/autoconf_2.71

 

 

编译并安装:

make -j8&& make install

 

 

 

配置系统环境:

修改  ~/.bashrc 文件,添加内容:

# autoconf
export PATH=/home/devilmaycry/anaconda3/mindspore_envs/autoconf_2.71/bin:$PATH

 

 

 

 

 

 重新载入  .bashrc 文件:

source ~/.bashrc

 

 

 

 

 

 

 

 

安装   libtool 

 下载地址:

wget https://ftpmirror.gnu.org/libtool/libtool-2.4.6.tar.gz

 

 

 解压:

tar -zxvf libtool-2.4.6.tar.gz

 

配置:

./configure  --prefix=/home/devilmaycry/anaconda3/mindspore_envs/libtool_2.4.6

编译并安装:

make -j8&& make install

 

 

配置系统环境:

修改  ~/.bashrc 文件,添加内容:

# libtool
export PATH=/home/devilmaycry/anaconda3/mindspore_envs/libtool_2.4.6/bin:$PATH

 

 

 

 重新载入  .bashrc 文件:

source ~/.bashrc

 

 

 

 

 

 

 

 

安装automake

下载:

wget https://ftp.gnu.org/gnu/automake/automake-1.16.3.tar.gz

 

 解压:

tar -zxvf automake-1.16.3.tar.gz

 

配置:

./configure  --prefix=/home/devilmaycry/anaconda3/mindspore_envs/automake_1.16.3

 

 

编译并安装:

make -j8&& make install

 

 

配置系统环境:

修改  ~/.bashrc 文件,添加内容:

# automake
export PATH=/home/devilmaycry/anaconda3/mindspore_envs/automake_1.16.3/bin:$PATH

 

 

 

 

 重新载入  .bashrc 文件:

source ~/.bashrc

 

 

 

 

 

 

 

安装flex

下载文件:

wget https://github.com/westes/flex/files/981163/flex-2.6.4.tar.gz

 

解压:

tar -zxvf flex-2.6.4.tar.gz

 

配置:

./configure  --prefix=/home/devilmaycry/anaconda3/mindspore_envs/flex_2.6.4

 

编译并安装:

make -j8&& make install

 

修改系统环境,修改 .bashrc文件,添加内容:

# flex
export PATH=/home/devilmaycry/anaconda3/mindspore_envs/flex_2.6.4/bin:$PATH

export LIBRARY_PATH=/home/devilmaycry/anaconda3/mindspore_envs/flex_2.6.4/lib:$LIBRARY_PATH
export LD_LIBRARY_PATH=/home/devilmaycry/anaconda3/mindspore_envs/flex_2.6.4/lib:$LD_LIBRARY_PATH

export C_INCLUDE_PATH=/home/devilmaycry/anaconda3/mindspore_envs/flex_2.6.4/include:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=$C_INCLUDE_PATH:$CPLUS_INCLUDE_PATH

 

 

 重新载入  .bashrc 文件:

source ~/.bashrc

 

 

 

 

 

 

 

 

 

 

 

 

安装Python环境和wheel

这里我们使用anaconda下的Python环境,anaconda的安装这里不进行讲解:

 

 

创建Python环境,命名mindspore_1.3.0:

conda create -n mindspore_1.3.0 python=3.7.5

 

 

安装 wheel :

激活Python环境:

activate  mindspore_1.3.0

 

安装:

pip install wheel

 

 

 

 

 

 

 

 

 

 

 

 

 

安装NUMA

 下载:

wget https://github.com/numactl/numactl/releases/download/v2.0.14/numactl-2.0.14.tar.gz

 

解压:

tar -zxvf numactl-2.0.14.tar.gz

 

配置:

./configure --prefix=/home/devilmaycry/anaconda3/mindspore_envs/numactl_2.0.14

 

 

 

编译并安装:

make -j8&& make install

 

修改系统环境,修改 .bashrc文件,添加内容:

# numa
export PATH=/home/devilmaycry/anaconda3/mindspore_envs/numactl_2.0.14/bin:$PATH

export LIBRARY_PATH=/home/devilmaycry/anaconda3/mindspore_envs/numactl_2.0.14/lib:$LIBRARY_PATH
export LD_LIBRARY_PATH=/home/devilmaycry/anaconda3/mindspore_envs/numactl_2.0.14/lib:$LD_LIBRARY_PATH

export C_INCLUDE_PATH=/home/devilmaycry/anaconda3/mindspore_envs/numactl_2.0.14/include:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=$C_INCLUDE_PATH:$CPLUS_INCLUDE_PATH

 

 重新载入  .bashrc 文件:

source ~/.bashrc

 

 

 

 

 

 

 

 =========================================================================

 

 

 

必要环境已经全部安装好,正式编译:

git clone https://gitee.com/mindspore/mindspore.git -b r1.3



bash build.sh -e gpu

 

 

 

失败。

 

 

报错信息:

---------------- MindSpore: build start ----------------
mkdir: 已创建目录 '/tmp/mindspore/build'
mkdir: 已创建目录 '/tmp/mindspore/build//package'
mkdir: 已创建目录 '/tmp/mindspore/build//package/mindspore'
mkdir: 已创建目录 '/tmp/mindspore/build//package/mindspore/lib'
子模组 'graphengine'(https://gitee.com/mindspore/graphengine.git)未对路径 'graphengine' 注册
正克隆到 '/tmp/mindspore/graphengine'...
子模组路径 'graphengine':检出 'acc2472c4119d70b579d7ac2f7a6bbf2c344af29'
子模组 'metadef'(https://gitee.com/ascend/metadef.git)未对路径 'metadef' 注册
正克隆到 '/tmp/mindspore/graphengine/metadef'...
子模组路径 'metadef':检出 '0a9ebe1c7f7b27554659f39e387110ac30d4a1e6'
子模组 'akg'(https://gitee.com/mindspore/akg.git)未对路径 'akg' 注册
正克隆到 '/tmp/mindspore/akg'...
子模组路径 'akg':检出 '796260887e9c87964aad87ab8154211060870fec'
start build mindspore project.
mkdir: 已创建目录 '/tmp/mindspore/build//mindspore'
-DDEBUG_MODE=off -DBUILD_PATH=/tmp/mindspore/build/ -DENABLE_INFER=ON -DENABLE_DUMP_PROTO=ON -DENABLE_DUMP_IR=on -DENABLE_PYTHON=on -DENABLE_MPI=ON -DENABLE_GPU=ON -DUSE_CUDA=ON -DCUDA_PATH= -DMS_REQUIRE_CUDA_VERSION=10.1 -DENABLE_CPU=ON -DX86_64_SIMD=off -DARM_SIMD=off -DENABLE_MINDDATA=ON -DUSE_GLOG=ON -DENABLE_AKG=ON -DENABLE_DEBUGGER=ON
-- The C compiler identification is GNU 7.3.0
-- The CXX compiler identification is GNU 7.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /home/devilmaycry/anaconda3/mindspore_envs/gcc_7.3.0/bin/gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /home/devilmaycry/anaconda3/mindspore_envs/gcc_7.3.0/bin/g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Python3: /home/devilmaycry/anaconda3/envs/mindspore_1.3.0/bin/python3.7 (found version "3.7.5") found components: Interpreter Development Development.Module Development.Embed
Python3 found, version: 3.7.5
Python3 library path:
Python3 interpreter: /home/devilmaycry/anaconda3/envs/mindspore_1.3.0/bin/python3.7
-- Found Patch: /home/devilmaycry/anaconda3/mindspore_envs/patch_2.7.6/bin/patch
PATCH_EXECUTABLE=/home/devilmaycry/anaconda3/mindspore_envs/patch_2.7.6/bin/patch
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
CMake Error at cmake/check_requirements.cmake:66 (message):
Required package gmp not found, please install gmp and try building
MindSpore again.
Call Stack (most recent call first):
CMakeLists.txt:13 (include)

-- Configuring incomplete, errors occurred!
See also "/tmp/mindspore/build/mindspore/CMakeFiles/CMakeOutput.log".
See also "/tmp/mindspore/build/mindspore/CMakeFiles/CMakeError.log".

 

 

 

 

 

 

 参考:

https://gitee.com/mindspore/mindspore/issues/I284ZL

 

 

========================================================================

 

 

 

 

 

 

 

另附其他环境的安装方式:

 

 

 

 

 

mpfr  的安装:

下载地址:

wget https://www.mpfr.org/mpfr-current/mpfr-4.1.0.tar.gz

 

 

解压文件:

tar -zxvf mpfr-4.1.0.tar.gz

 

配置:

./configure --prefix=/home/devilmaycry/anaconda3/mindspore_envs/mpfr_4.1.0/

 

 

 编译安装:

make && make install

 

配置文件: 添加内容到  .bashrc 文件中

# mpfr
export LIBRARY_PATH=/home/devilmaycry/anaconda3/mindspore_envs/mpfr_4.1.0/lib:$LIBRARY_PATH
export LD_LIBRARY_PATH=/home/devilmaycry/anaconda3/mindspore_envs/mpfr_4.1.0/lib:$LD_LIBRARY_PATH

export C_INCLUDE_PATH=/home/devilmaycry/anaconda3/mindspore_envs/mpfr_4.1.0/include:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=$C_INCLUDE_PATH:$CPLUS_INCLUDE_PATH

 

 

测试安装及配置是否成功:

代码: #test.cpp

#include <stdio.h>
#include <mpfr.h>
int main (void)
{
  printf ("MPFR library: %-12s\nMPFR header:  %s (based on %d.%d.%d)\n",
          mpfr_get_version (), MPFR_VERSION_STRING, MPFR_VERSION_MAJOR,
          MPFR_VERSION_MINOR, MPFR_VERSION_PATCHLEVEL);
  return 0;
}

 

编译及运行:

gcc test.cpp -o test  -lmpfr

 

 

 

 

 

 

 

 

 

 

 

 

 

 

mpc  的安装:

下载: 

wget  https://ftp.gnu.org/gnu/mpc/mpc-1.2.1.tar.gz

 

解压:

tar -zxvf mpc-1.2.1.tar.gz

 

 配置:

./configure --prefix=/home/devilmaycry/anaconda3/mindspore_envs/mpc_1.2.1/

 

 

 

 编译安装:

make && make install

 

 

 修改   .bashrc  文件,添加内容:

# mpc
export LIBRARY_PATH=/home/devilmaycry/anaconda3/mindspore_envs/mpc_1.2.1/share:$LIBRARY_PATH
export LD_LIBRARY_PATH=/home/devilmaycry/anaconda3/mindspore_envs/mpc_1.2.1/lib:$LD_LIBRARY_PATH

export C_INCLUDE_PATH=/home/devilmaycry/anaconda3/mindspore_envs/mpc_1.2.1/include:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=$C_INCLUDE_PATH:$CPLUS_INCLUDE_PATH

 

 

 

 

 

 

 

 

==================================================================

 

posted on 2021-07-21 22:58  Angry_Panda  阅读(637)  评论(2编辑  收藏  举报

导航