Installing from Sources

Download and Setup

You can download PaddlePaddle from the github source.

git clone https://github.com/PaddlePaddle/Paddle paddle
cd paddle

Requirements

To compile the source code, your computer must be equipped with the following dependencies.

  • Compiler: GCC >= 4.8 or Clang >= 3.3 (AppleClang >= 5.1) and gfortran compiler
  • CMake: CMake >= 3.0 (at least CMake 3.4 on Mac OS X)
  • BLAS: MKL, OpenBlas or ATLAS
  • Python: only support Python 2.7

Note: For CUDA 7.0 and CUDA 7.5, GCC 5.0 and up are not supported! For CUDA 8.0, GCC versions later than 5.3 are not supported!

Options

PaddlePaddle supports some build options.

Optional Description
WITH_GPUCompile PaddlePaddle with NVIDIA GPU
WITH_AVXCompile PaddlePaddle with AVX intrinsics
WITH_DSOCompile PaddlePaddle with dynamic linked CUDA
WITH_TESTINGCompile PaddlePaddle with unit testing
WITH_SWIG_PYCompile PaddlePaddle with inference api
WITH_STYLE_CHECKCompile PaddlePaddle with style check
WITH_PYTHONCompile PaddlePaddle with python interpreter
WITH_DOUBLECompile PaddlePaddle with double precision
WITH_RDMACompile PaddlePaddle with RDMA support
WITH_TIMERCompile PaddlePaddle with stats timer
WITH_PROFILERCompile PaddlePaddle with GPU profiler
WITH_DOCCompile PaddlePaddle with documentation
ON_COVERALLSCompile PaddlePaddle with code coverage
COVERALLS_UPLOADPackage code coverage data to coveralls
ON_TRAVISExclude special unit test on Travis CI

Note:

  • The GPU version works best with Cuda Toolkit 8.0 and cuDNN v5.
  • Other versions like Cuda Toolkit 7.0, 7.5 and cuDNN v3, v4 are also supported.
  • To utilize cuDNN v5, Cuda Toolkit 7.5 is prerequisite and vice versa.

As a simple example, consider the following:

  1. BLAS Dependencies(optional)

    CMake will search BLAS libraries from system. If not found, OpenBLAS will be downloaded, built and installed automatically. To utilize preinstalled BLAS, you can simply specify MKL, OpenBLAS or ATLAS via MKL_ROOT, OPENBLAS_ROOT or ATLAS_ROOT.

    # specify MKL
    cmake .. -DMKL_ROOT=<mkl_path>
    # or specify OpenBLAS
    cmake .. -DOPENBLAS_ROOT=<openblas_path>
    
  2. Doc Dependencies(optional)

    To generate PaddlePaddle’s documentation, install dependencies and set -DWITH_DOC=ON as follows:

    pip install 'sphinx>=1.4.0'
    pip install sphinx_rtd_theme recommonmark
    
    # install doxygen on Ubuntu
    sudo apt-get install doxygen 
    # install doxygen on Mac OS X
    brew install doxygen
    
    # active docs in cmake
    cmake .. -DWITH_DOC=ON`
    

Build on Ubuntu 14.04

Install Dependencies

  • Paddle Dependencies

    # necessary
    sudo apt-get update
    sudo apt-get install -y git curl gcc g++ gfortran make build-essential automake
    sudo apt-get install -y python python-pip python-numpy libpython-dev bison
    sudo pip install 'protobuf==3.1.0.post1'
    
    # install cmake 3.4
    curl -sSL https://cmake.org/files/v3.4/cmake-3.4.1.tar.gz | tar -xz && \
        cd cmake-3.4.1 && ./bootstrap && make -j4 && sudo make install && \
        cd .. && rm -rf cmake-3.4.1
    
  • GPU Dependencies (optional)

    To build GPU version, you will need the following installed:

      1. a CUDA-capable GPU
      2. A supported version of Linux with a gcc compiler and toolchain
      3. NVIDIA CUDA Toolkit (available at http://developer.nvidia.com/cuda-downloads)
      4. NVIDIA cuDNN Library (availabel at https://developer.nvidia.com/cudnn)
    

    The CUDA development environment relies on tight integration with the host development environment, including the host compiler and C runtime libraries, and is therefore only supported on distribution versions that have been qualified for this CUDA Toolkit release.

    After downloading cuDNN library, issue the following commands:

    sudo tar -xzf cudnn-7.5-linux-x64-v5.1.tgz -C /usr/local
    sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*
    

    Then you need to set LD_LIBRARY_PATH, PATH environment variables in ~/.bashrc.

    export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
    export PATH=/usr/local/cuda/bin:$PATH
    

Build and Install

As usual, the best option is to create build folder under paddle project directory.

mkdir build && cd build

Finally, you can build and install PaddlePaddle:

# you can add build option here, such as:    
cmake .. -DCMAKE_INSTALL_PREFIX=<path to install>
# please use sudo make install, if you want to install PaddlePaddle into the system
make -j `nproc` && make install
# set PaddlePaddle installation path in ~/.bashrc
export PATH=<path to install>/bin:$PATH
# install PaddlePaddle Python modules.
sudo pip install <path to install>/opt/paddle/share/wheels/*.whl

Build on Centos 7

Install Dependencies

  • CPU Dependencies

    # necessary
    sudo yum update
    sudo yum install -y epel-release
    sudo yum install -y make cmake3 python-devel python-pip gcc-gfortran swig git
    sudo pip install wheel numpy
    sudo pip install 'protobuf>=3.0.0'
    
  • GPU Dependencies (optional)

    To build GPU version, you will need the following installed:

      1. a CUDA-capable GPU
      2. A supported version of Linux with a gcc compiler and toolchain
      3. NVIDIA CUDA Toolkit (available at http://developer.nvidia.com/cuda-downloads)
      4. NVIDIA cuDNN Library (availabel at https://developer.nvidia.com/cudnn)
    

    The CUDA development environment relies on tight integration with the host development environment, including the host compiler and C runtime libraries, and is therefore only supported on distribution versions that have been qualified for this CUDA Toolkit release.

    After downloading cuDNN library, issue the following commands:

    sudo tar -xzf cudnn-7.5-linux-x64-v5.1.tgz -C /usr/local
    sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*
    

    Then you need to set LD_LIBRARY_PATH, PATH environment variables in ~/.bashrc.

    export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
    export PATH=/usr/local/cuda/bin:$PATH
    

Build and Install

As usual, the best option is to create build folder under paddle project directory.

mkdir build && cd build

Finally, you can build and install PaddlePaddle:

# you can add build option here, such as:    
cmake3 .. -DCMAKE_INSTALL_PREFIX=<path to install>
# please use sudo make install, if you want to install PaddlePaddle into the system
make -j `nproc` && make install
# set PaddlePaddle installation path in ~/.bashrc
export PATH=<path to install>/bin:$PATH
# install PaddlePaddle Python modules.
sudo pip install <path to install>/opt/paddle/share/wheels/*.whl