build.sh 1.5 KB
Newer Older
Z
zhangjinchao01 已提交
1 2 3 4 5 6 7 8 9
#!/bin/bash

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

trap 'abort' 0
set -e
10 11 12 13
if [ ${USE_UBUNTU_MIRROR} == "ON" ]; then
    sed -i 's#http://archive\.ubuntu\.com/ubuntu/#mirror://mirrors\.ubuntu\.com/mirrors\.txt#g'\
      /etc/apt/sources.list
fi
Z
zhangjinchao01 已提交
14 15 16 17 18
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 已提交
19 20
if [ ${WITH_GPU} == 'ON' ]; then
  ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so /usr/lib/libcudnn.so
Z
zhangjinchao01 已提交
21
fi
Y
yuyang18 已提交
22

Z
zhangjinchao01 已提交
23 24 25 26 27
cd ~
git clone https://github.com/baidu/Paddle.git paddle
cd paddle
mkdir build
cd build
28
cmake .. -DWITH_DOC=OFF -DWITH_GPU=${WITH_GPU} -DWITH_SWIG_PY=ON\
Y
Yu Yang 已提交
29
   -DCUDNN_ROOT=/usr/ -DWITH_STYLE_CHECK=OFF -DWITH_AVX=${WITH_AVX}
Z
zhangjinchao01 已提交
30 31 32 33 34 35 36 37 38
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\
39 40 41
	          sed grep graphviz libjpeg-dev zlib1g-dev
  pip ${PIP_GENERAL_ARGS} install ${PIP_INSTALL_ARGS}  BeautifulSoup docopt \
    PyYAML pillow
Z
zhangjinchao01 已提交
42 43 44 45 46 47 48
fi
if [ ${IS_DEVEL} == "OFF" ]; then  # clean build packages.
  cd ~
  rm -rf paddle
fi
apt-get clean -y
trap : 0