裸机编译安装Paddle示例【Python2】【Python3】

说明

机器P40*8

操作系统centos 6.x,系统内核版本3.10.0_3-0-0-26,glibc 版本2.12

驱动版本418.39,cuda版本9.2

需要有root权限(安装nccl2)和下载编译依赖

另外glibc版本过低,并不满足nccl2官方要求。

官方推荐升级操作系统版本到centos 7 ,或者使用docker

 

安装gcc 4.8.5

wget ftp://ftp.gnu.org/gnu/gcc/gcc-4.8.5/gcc-4.8.5.tar.gz
tar xvf gcc-4.8.5.tar.gz
cd gcc-4.8.5
#下载编译依赖,如果下载失败则手动下载
./contrib/download_prerequisites
mkdir build
cd build
../configure --prefix=/home/huxiaoguang/bin/gcc-4.8.5 --disable-multilib
make -j 8
make install

 

安装anaconda3

wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-5.3.1-Linux-x86_64.sh
sh Anaconda3-5.3.1-Linux-x86_64.sh
#自动设置环境变量到.bashrc
#重新登录使环境变量生效
which python
python -V
conda create -n paddle-1.6
conda env list
conda activate paddle-1.6
#安装protobuf
pip install protobuf

安装cmake

wget https://cmake.org/files/v3.5/cmake-3.5.2.tar.gz
tar xvzf cmake-3.5.2.tar.gz
cd cmake-3.5.2
./bootstrap --prefix=/home/huxiaoguang/bin/cmake-3.5.2
make -j 8
make install

安装git

wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.23.0.tar.gz
tar xvf git-2.23.0.tar.gz
cd git-2.23.0
# centos自带的curl, ssl库版本过低,需要使用anaconda3的库版本
export LD_LIBRARY_PATH=/home/huxiaoguang/anaconda3/lib:$LD_LIBRARY_PATH
./configure --prefix=/home/huxiaoguang/bin/git-2.23.0
make
make install
echo "export PATH=/home/huxiaoguang/bin/git-2.23.0/bin:\$PATH" >> ~/.bash_profile
source ~/.bash_profile
which git
git --version

以下步骤不一定需要,通常anaconda的lib版本可满足git的使用需求。

测试git clone命令,如提示 SSL connect error,则有可能是nss版本过低造成,需要升级nss库。

因为Paddle编译时需要通过git下载依赖的代码库,所以需要保持git命令能正常工作。

wget https://ftp.mozilla.org/pub/security/nss/releases/NSS_3_37_1_RTM/src/nss-3.37.1-with-nspr-4.19.tar.gz
tar xvzf nss-3.37.1-with-nspr-4.19.tar.gz
cd nss-3.37.1
export BUILD_OPT=1
export USE_64=1
make nss_build_all
cd ../dist
cp -r Linux3.10_x86_64_cc_glibc_PTH_64_OPT.OBJ /home/huxiaoguang/bin/nss-3.37

安装cudnn&nccl2

# 解压后放到特定目录
wget https://developer.nvidia.com/compute/machine-learning/cudnn/secure/7.6.4.38/Production/9.2_20190923/cudnn-9.2-linux-x64-v7.6.4.38.tgz

wget https://developer.nvidia.com/compute/machine-learning/nccl/secure/v2.4/prod/nccl-repo-rhel7-2.4.8-ga-cuda9.2-1-1.x86_64.rpm
# 查询安装目录
rpm -qpl nccl-repo-rhel7-2.4.8-ga-cuda9.2-1-1.x86_64.rpm
# 无法修改安装目录,必须使用root安装
sudo rpm -ivh nccl-repo-rhel7-2.4.8-ga-cuda9.2-1-1.x86_64.rpm
sudo rpm -qpl /var/nccl-repo-2.4.8-ga-cuda9.2/libnccl-2.4.8-1+cuda9.2.x86_64.rpm
#/usr/lib64/libnccl.so.2
#/usr/lib64/libnccl.so.2.4.8
#/usr/share/doc/libnccl-2.4.8
#/usr/share/doc/libnccl-2.4.8/LICENSE.txt
sudo rpm -ivh /var/nccl-repo-2.4.8-ga-cuda9.2/libnccl-2.4.8-1+cuda9.2.x86_64.rpm 

sudo rpm -qpl /var/nccl-repo-2.4.8-ga-cuda9.2/libnccl-devel-2.4.8-1+cuda9.2.x86_64.rpm
#/usr/include/nccl.h
#/usr/lib64/libnccl.so
#/usr/share/doc/libnccl-devel-2.4.8
#/usr/share/doc/libnccl-devel-2.4.8/LICENSE.txt
sudo rpm -ivh /var/nccl-repo-2.4.8-ga-cuda9.2/libnccl-devel-2.4.8-1+cuda9.2.x86_64.rpm

 

编译Paddle

git clone https://github.com/PaddlePaddle/Paddle.git
cd paddle
git checkout v1.6.0
mkdir build
cd build
cmake .. -DPY_VERSION=3.7 -DPADDLE_VERSION=1.6.0 -DWITH_GPU=ON -DWITH_TESTING=OFF -DCMAKE_BUILD_TYPE=Release -DCUDNN_ROOT=/home/huxiaoguang/bin/cudnn-v7.6.4/cuda
# 网络问题可能会造成编译依赖下载失败,可以适当调小make时的并发数
make -j 6
# 安装whl包
cd python/dist
pip install *.whl
# 验证是否成功
cd ~
python
>>> import paddle
>>> print(paddle.__version__)
# 1.6.0
 
已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 酷酷鲨 设计师:CSDN官方博客 返回首页