1
1
Build and Install
2
2
=================
3
3
4
- ## Requirement
4
+ * [ 1. Requirement] ( #Requirement )
5
+ * [ 2. Build on Ubuntu] ( #ubuntu )
6
+ * [ 3. Build on Mac OS X] ( #mac )
7
+
8
+ ## <span id =" Requirement " >Requirement</span >
5
9
6
10
### Dependents
7
11
@@ -28,7 +32,7 @@ PaddlePaddle also support some build options, you have to install related librar
28
32
- ** WITH_STYLE_CHECK** : Style check for source code
29
33
30
34
31
- ## Building on Ubuntu14.04
35
+ ## < span id = " ubuntu " > Building on Ubuntu14.04</ span >
32
36
33
37
### Install Dependencies
34
38
@@ -44,7 +48,7 @@ sudo apt-get install libgflags-dev
44
48
sudo apt-get install libgtest-dev
45
49
sudo pip install wheel
46
50
pushd /usr/src/gtest
47
- cmake .
51
+ cmake ..
48
52
make
49
53
sudo cp * .a /usr/lib
50
54
popd
@@ -102,19 +106,19 @@ Here are some examples of cmake command with different options:
102
106
** only cpu**
103
107
104
108
``` bash
105
- cmake -DWITH_GPU=OFF -DWITH_DOC=OFF
109
+ cmake -DWITH_GPU=OFF -DWITH_DOC=OFF ..
106
110
```
107
111
108
112
** gpu**
109
113
110
114
``` bash
111
- cmake -DWITH_GPU=ON -DWITH_DOC=OFF
115
+ cmake -DWITH_GPU=ON -DWITH_DOC=OFF ..
112
116
```
113
117
114
118
** gpu with doc and swig**
115
119
116
120
``` bash
117
- cmake -DWITH_GPU=ON -DWITH_DOC=ON -DWITH_SWIG_PY=ON
121
+ cmake -DWITH_GPU=ON -DWITH_DOC=ON -DWITH_SWIG_PY=ON ..
118
122
```
119
123
120
124
Finally, you can download source code and build:
@@ -139,3 +143,129 @@ And if you set WITH_SWIG_PY=ON, you have to install related python predict api a
139
143
``` bash
140
144
pip install < path to install> /opt/paddle/share/wheels/* .whl
141
145
```
146
+ ## <span id =" mac " >Building on Mac OS X</span >
147
+
148
+ ### Prerequisites
149
+ This guide is based on Mac OS X 10.11 (El Capitan). Note that if you are running an up to date version of OS X,
150
+ you will already have Python 2.7.10 and Numpy 1.8 installed.
151
+
152
+ The best option is to use the package manager homebrew to handle installations and upgrades for you.
153
+ To install homebrew, first open a terminal window (you can find Terminal in the Utilities folder in Applications), and issue the command:
154
+
155
+ ``` bash
156
+ # install brew
157
+ /usr/bin/ruby -e " $( curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install) "
158
+ # install pip
159
+ easy_install pip
160
+ ```
161
+
162
+ ### Install Dependencies
163
+
164
+ - ** CPU Dependencies**
165
+
166
+ ``` bash
167
+ # Install fundamental dependents
168
+ brew install glog gflags cmake protobuf openblas
169
+
170
+ # Install google test on Mac OS X
171
+ # Download gtest 1.7.0
172
+ wget https://github.com/google/googletest/archive/release-1.7.0.tar.gz
173
+ tar -xvf googletest-release-1.7.0.tar.gz && cd googletest-release-1.7.0
174
+ # Build gtest
175
+ mkdir build && cmake ..
176
+ make
177
+ # Install gtest library
178
+ sudo cp -r ../include/gtest /usr/local/include/
179
+ sudo cp lib* .a /usr/local/lib
180
+ ```
181
+
182
+
183
+ - ** GPU Dependencies(optional)**
184
+
185
+ If you need to build GPU version, the first thing you need is a machine that has NVIDIA GPU and CUDA installed.
186
+ And you also need to install cuDNN.
187
+
188
+ You can download CUDA toolkit and cuDNN from nvidia website:
189
+
190
+ ``` bash
191
+ https://developer.nvidia.com/cuda-downloads
192
+ https://developer.nvidia.com/cudnn
193
+ ```
194
+ You can copy cuDNN files into the CUDA toolkit directory, for instance:
195
+
196
+ ``` bash
197
+ sudo tar -xzf cudnn-7.5-osx-x64-v5.0-ga.tgz -C /usr/local
198
+ sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*
199
+ ```
200
+ Then you need to set DYLD\_ LIBRARY\_ PATH, CUDA\_ HOME and PATH environment variables in ~ /.bashrc.
201
+
202
+ ``` bash
203
+ export DYLD_LIBRARY_PATH=/usr/local/cuda/lib:$DYLD_LIBRARY_PATH
204
+ export PATH=/usr/local/cuda/bin:$PATH
205
+ ```
206
+ - ** Python Dependencies(optional)**
207
+
208
+ If you want to compile PaddlePaddle with python predict API, you need to add -DWITH_SWIG_PY=ON in cmake command and install these first:
209
+
210
+ ``` bash
211
+ brew install swig
212
+ ```
213
+
214
+ - ** Doc Dependencies(optional)**
215
+
216
+ If you want to compile PaddlePaddle with doc, you need to add -DWITH_DOC=ON in cmake command and install these first:
217
+
218
+ ``` bash
219
+ pip install ' sphinx>=1.4.0'
220
+ pip install sphinx_rtd_theme breathe recommonmark
221
+ brew install doxygen
222
+ ```
223
+
224
+ ### Build and Install
225
+
226
+ CMake can find dependent libraries in system default paths firstly.
227
+ After installing some optional libraries, corresponding build option will be on automatically (for instance, glog, gtest and gflags).
228
+ If not found, you have to set following variables manually via CMake command (CUDNN_ROOT, ATLAS_ROOT, MKL_ROOT, OPENBLAS_ROOT).
229
+
230
+ Here are some examples of CMake command with different options:
231
+
232
+ ** only cpu**
233
+
234
+ ``` bash
235
+ cmake -DWITH_GPU=OFF -DWITH_DOC=OFF ..
236
+ ```
237
+
238
+ ** gpu**
239
+
240
+ ``` bash
241
+ cmake -DWITH_GPU=ON -DWITH_DOC=OFF ..
242
+ ```
243
+
244
+ ** gpu with doc and swig**
245
+
246
+ ``` bash
247
+ cmake -DWITH_GPU=ON -DWITH_DOC=ON -DWITH_SWIG_PY=ON ..
248
+ ```
249
+
250
+ Finally, you can download source code and build:
251
+
252
+ ``` bash
253
+ git clone https://github.com/baidu/Paddle paddle
254
+ cd paddle
255
+ mkdir build
256
+ cd build
257
+ # you can add build option here, such as:
258
+ cmake -DWITH_GPU=ON -DWITH_DOC=OFF -DCMAKE_INSTALL_PREFIX=< path to install> ..
259
+ # please use sudo make install, if you want
260
+ # to install PaddlePaddle into the system
261
+ make -j ` nproc` && make install
262
+ # PaddlePaddle installation path
263
+ export PATH=< path to install> /bin:$PATH
264
+ ```
265
+ ** Note**
266
+
267
+ And if you set WITH_SWIG_PY=ON, you have to install related python predict api at the same time:
268
+
269
+ ``` bash
270
+ sudo pip install < path to install> /opt/paddle/share/wheels/* .whl
271
+ ```
0 commit comments