Getting started in depth learning: detailed Ubuntu Paddlepaddle source code compilation installation

Source: Internet
Author: User
Tags curl git clone

Paddlepaddle is a deep learning framework for Baidu Open source, paddle provides the paddle book for those who learn the depth of the introduction of the people is simply convenient.

Want to use paddle model training must be installed first, this article mainly detailed records paddle CPU and GPU source code compilation installation. Personally think the source code is the most simple and brutal, and transparent. content installation relies on Paddlepaddle CPU source code compilation installation Paddlepaddle GPU source compilation installation must address the following dependencies before formal installation

Note❕⚠️⚠️⚠️ this piece is very critical, the following dependencies as long as there is not satisfied with the words, certainly compile problems. Both CPU and GPU installations have to address the following dependencies. 1.1

Check the version of GCC on your computer with the gcc–version command, and if below 4.8, see this article to upgrade GCC to over 4.8. 1.2

Use Cmake–version to view the version of CMake, if the version is less than 3.0 (for Linux) 3.4 (for Mac OS), upgrade your computer's CMake version. The following commands can install cmake3.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
1.3

Use Python–version to see if your Python is python27, in general, Mac and Linux with Python27. 1.4

Use the Go version command to see if your computer has a going environment, and if not, use sudo apt-get install golang This command to install 1.5 install other dependencies

$ sudo apt-get install-y git curl Gfortran make build-essential automake swig libboost-all-dev
$ sudo apt-get install -y python-pip python-numpy libpython-dev bison
$ pip Install--upgrade pip
$ sudo pip install ' Protobuf==3.1.0.po St1 ' 
$ sudo pip install wheel
paddle CPU Compilation and installation 1. Clone paddle code from GitHub to local
$ git clone https://github.com/PaddlePaddle/Paddle.git  paddle
$ cd Paddle
2. CMake Generation Makefile
$ mkdir Build
$ cd Build
$ cmake ...

Note: If you use the command CMake ... To generate makefile, the final paddle will be installed under/usr/local, and if you want to install to another path (we assume that the path is $PADDLE _install_path), we can write this:
CMake.. -dcmake_install_prefix= $PADDLE _install_path so that the final compiled paddle will be installed under $PADDLE _install_path. 3. Compile and install

$ Make-j ' nproc '
$ sudo make install

Note: Because I am using the default installation path, I will eventually generate the file in the Global Environment (/usr/local), so make time to add sudo. At the end of the run, paddle has been compiled and the following log will appear on my computer:

This means that our paddle has been installed and we can use the command paddle version to see if the installation was successful:

$ paddle Version
Paddlepaddle 0.10.0, compiled with
    with_avx:off
    with_gpu:off With_mkldnn:off With_mklml:off
    with_double:off
    with_python:on
    with_rdma:off
    With_timer:off
4. Install Paddle Python interface

As you can see from the log in the previous step, a/usr/local/opt/paddle/share/wheels/paddlepaddle-0.10.0-cp27-none-linux_x86_ is generated after making install 64.WHL files. Run the following command for Paddle python installation:

$ sudo pip install-u  /USR/LOCAL/OPT/PADDLE/SHARE/WHEELS/PADDLEPADDLE-0.10.0-CP27-NONE-LINUX_X86_64.WHL
5. Test
$ python
>>>  import paddle.v2 as Paddle

If the Importerror:no module named paddle is not present, congratulations, you have successfully compiled the installation paddle for CPU. 6. Run a demo

From the GitHub clone paddle the code in book:

$ cd ~/
$ git clone https://github.com/PaddlePaddle/book.git  paddle_book
$ cd Paddle_book/01.fit_a_line
$ python train.py
paddle GPU Compilation and installation 1. Installation of CUDA and CUDNN

Install CUDA 8.0

$ sudo apt-get update && sudo apt-get install wget-y--no-install-recommends
$ wget "Http://developer.downloa D.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_8.0.61-1_amd64.deb "
$ sudo dpkg-i Cuda-repo-ubuntu1604_8.0.61-1_amd64.deb
$ sudo apt-get update
$ sudo apt-get install Cuda

Install cuDNN5.1

$ wget http://developer.download.nvidia.com/compute/redist/cudnn/v5.1/cudnn-8.0-linux-x64-v5.1.tgz
$ sudo tar- XZF cudnn-8.0-linux-x64-v5.1.tgz-c/usr/local
$ rm cudnn-8.0-linux-x64-v5.1.tgz && sudo ldconfig
2. Compile the installation (same as CPU process)
$ git clone https://github.com/PaddlePaddle/Paddle.git  paddle_gpu
$ cd paddle_gpu
$ mkdir Build
$ cd Build
$ cmake ... 
$ Make-j ' nproc '
$ sudo make install
$ sudo pip install-u  /usr/local/opt/paddle/share/wheels/ Paddlepaddle-0.10.0-cp27-none-linux_x86_64.whl  
3. Test
$ paddle Version
Paddlepaddle 0.10.0, compiled with
    with_avx:off
    with_gpu:on With_mkldnn:off With_mklml:off
    with_double:off
    with_python:on
    with_rdma:off
    With_timer:off

You can see that WITH_GPU is on state 4. Run a Demo

From the GitHub clone paddle the code in book:

$ cd ~/
$ git clone https://github.com/PaddlePaddle/book.git  paddle_book
$ cd Paddle_book/01.fit_a_ Line
$ export with_gpu=1
$ python train.py

Here, paddle compiled installation has been said almost, but because everyone's machine environment is not the same, it is likely that you follow the above method to install the time will encounter problems, you can leave a message, or go here to mention Issue,paddle comrades reply is very soon.

Finally, it is highly recommended to take a look at the paddle book, which allows you to quickly understand the application of depth learning in the field of image NLP and recommendation.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.