build.sh 1.4 KB
Newer Older
Y
yuyang18 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#!/bin/bash

function abort(){
    echo "An error occurred. Exiting..." 1>&2
    exit 1
}

trap 'abort' 0
set -e
sed -i 's#http://archive\.ubuntu\.com/ubuntu/#mirror://mirrors\.ubuntu\.com/mirrors\.txt#g' /etc/apt/sources.list
apt-get update
apt-get install -y cmake libprotobuf-dev protobuf-compiler git \
    libgoogle-glog-dev libgflags-dev libatlas-dev libatlas3-base g++ m4 python-pip\
    python-protobuf python-numpy python-dev swig

Y
yuyang18 已提交
16 17
if [ ${WITH_GPU} == 'ON' ]; then
  ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so /usr/lib/libcudnn.so
Y
yuyang18 已提交
18
fi
Y
yuyang18 已提交
19

Y
yuyang18 已提交
20 21 22 23 24
cd ~
git clone https://github.com/baidu/Paddle.git paddle
cd paddle
mkdir build
cd build
Y
yuyang18 已提交
25
cmake .. -DWITH_DOC=OFF -DWITH_GPU=${WITH_GPU} -DWITH_SWIG_PY=ON -DCUDNN_ROOT=/usr/
Y
yuyang18 已提交
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
make -j `nproc`
# because durning make install, there are several warning, so set +e, do not cause abort
make install
echo 'export LD_LIBRARY_PATH=/usr/lib64:${LD_LIBRARY_PATH}' >> /etc/profile
pip ${PIP_GENERAL_ARGS} install ${PIP_INSTALL_ARGS} /usr/local/opt/paddle/share/wheels/*.whl
paddle version  # print version after build

if [ ${WITH_DEMO} == "ON" ]; then
  apt-get install -y wget unzip perl python-matplotlib tar xz-utils bzip2 gzip coreutils\
	          sed grep graphviz 
  pip ${PIP_GENERAL_ARGS} install ${PIP_INSTALL_ARGS}  BeautifulSoup docopt PyYAML
fi
if [ ${IS_DEVEL} == "OFF" ]; then  # clean build packages.
  cd ~
  rm -rf paddle
fi
apt-get clean -y
trap : 0