build_from_source.html 29.3 KB
Newer Older
1 2


Y
Yu Yang 已提交
3 4 5 6 7 8 9 10
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
11
    <title>Installing from Sources &#8212; PaddlePaddle  documentation</title>
Y
Yu Yang 已提交
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
    
    <link rel="stylesheet" href="../_static/classic.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
    <link rel="top" title="PaddlePaddle  documentation" href="../index.html" />
    <link rel="up" title="Build And Install PaddlePaddle" href="index.html" />
    <link rel="next" title="Contribute to PaddlePaddle" href="contribute_to_paddle.html" />
    <link rel="prev" title="Build And Install PaddlePaddle" href="index.html" /> 
33 34 35 36 37 38 39 40 41 42
<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "//hm.baidu.com/hm.js?b9a314ab40d04d805655aab1deee08ba";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>

Y
Yu Yang 已提交
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
  </head>
  <body role="document">
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="contribute_to_paddle.html" title="Contribute to PaddlePaddle"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="index.html" title="Build And Install PaddlePaddle"
             accesskey="P">previous</a> |</li>
60 61
        <li class="nav-item nav-item-0"><a href="../index.html">PaddlePaddle  documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="index.html" accesskey="U">Build And Install PaddlePaddle</a> &#187;</li> 
Y
Yu Yang 已提交
62 63 64 65 66 67 68 69
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
70 71
  <div class="section" id="installing-from-sources">
<span id="installing-from-sources"></span><h1>Installing from Sources<a class="headerlink" href="#installing-from-sources" title="Permalink to this headline"></a></h1>
Y
Yu Yang 已提交
72
<ul class="simple">
73 74 75 76
<li><a class="reference external" href="#download">1. Download and Setup</a></li>
<li><a class="reference external" href="#requirements">2. Requirements</a></li>
<li><a class="reference external" href="#ubuntu">3. Build on Ubuntu</a></li>
<li><a class="reference external" href="#mac">4. Build on Mac OS X</a></li>
Y
Yu Yang 已提交
77
</ul>
78 79 80 81 82 83
<div class="section" id="span-id-download-download-and-setup-span">
<span id="span-id-download-download-and-setup-span"></span><h2><span id="download">Download and Setup</span><a class="headerlink" href="#span-id-download-download-and-setup-span" title="Permalink to this headline"></a></h2>
<p>You can download PaddlePaddle from the <a class="reference external" href="https://github.com/gangliao/Paddle">github source</a>.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>git clone https://github.com/baidu/Paddle paddle
</pre></div>
</div>
Y
Yu Yang 已提交
84
</div>
85 86 87 88 89
<div class="section" id="span-id-requirements-requirements-span">
<span id="span-id-requirements-requirements-span"></span><h2><span id="requirements">Requirements</span><a class="headerlink" href="#span-id-requirements-requirements-span" title="Permalink to this headline"></a></h2>
<p>To compile the source code, your computer must be equipped with GCC &gt;=4.6 or Clang Compiler.</p>
<div class="section" id="dependencies">
<span id="dependencies"></span><h3>Dependencies<a class="headerlink" href="#dependencies" title="Permalink to this headline"></a></h3>
Y
Yu Yang 已提交
90
<ul class="simple">
91 92 93 94
<li><strong>CMake</strong>: version &gt;= 2.8</li>
<li><strong>BLAS</strong>: MKL, OpenBlas or ATLAS</li>
<li><strong>protobuf</strong>: version &gt;= 2.4, <strong>Note: 3.x is not supported</strong></li>
<li><strong>python</strong>: only python 2.7 is supported currently</li>
Y
Yu Yang 已提交
95
</ul>
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
</div>
<div class="section" id="options">
<span id="options"></span><h3>Options<a class="headerlink" href="#options" title="Permalink to this headline"></a></h3>
<p>PaddlePaddle supports some build options. To enable it, first you need to install the related libraries.</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">Optional</span>            <span class="o">|</span> <span class="n">Description</span>
<span class="o">------------</span>        <span class="o">|</span> <span class="p">:</span><span class="o">-----------</span>
<span class="o">**</span><span class="n">WITH_GPU</span><span class="o">**</span>        <span class="o">|</span> <span class="n">Compile</span> <span class="k">with</span> <span class="n">GPU</span> <span class="n">mode</span><span class="o">.</span>
<span class="o">**</span><span class="n">WITH_DOUBLE</span><span class="o">**</span>     <span class="o">|</span> <span class="n">Compile</span> <span class="k">with</span> <span class="n">double</span> <span class="n">precision</span> <span class="n">floating</span><span class="o">-</span><span class="n">point</span><span class="p">,</span> <span class="n">default</span><span class="p">:</span> <span class="n">single</span> <span class="n">precision</span><span class="o">.</span> <span class="o">|</span>
<span class="o">**</span><span class="n">WITH_GLOG</span><span class="o">**</span>       <span class="o">|</span> <span class="n">Compile</span> <span class="k">with</span> <span class="n">glog</span><span class="o">.</span> <span class="n">If</span> <span class="ow">not</span> <span class="n">found</span><span class="p">,</span> <span class="n">default</span><span class="p">:</span> <span class="n">an</span> <span class="n">internal</span> <span class="n">log</span> <span class="n">implementation</span><span class="o">.</span>
<span class="o">**</span><span class="n">WITH_GFLAGS</span><span class="o">**</span>     <span class="o">|</span> <span class="n">Compile</span> <span class="k">with</span> <span class="n">gflags</span><span class="o">.</span> <span class="n">If</span> <span class="ow">not</span> <span class="n">found</span><span class="p">,</span> <span class="n">default</span><span class="p">:</span> <span class="n">an</span> <span class="n">internal</span> <span class="n">flag</span> <span class="n">implementation</span><span class="o">.</span>
<span class="o">**</span><span class="n">WITH_TESTING</span><span class="o">**</span>    <span class="o">|</span> <span class="n">Compile</span> <span class="k">with</span> <span class="n">gtest</span> <span class="k">for</span> <span class="n">PaddlePaddle</span><span class="s1">&#39;s unit testing. </span>
<span class="o">**</span><span class="n">WITH_DOC</span><span class="o">**</span>        <span class="o">|</span> <span class="n">Compile</span> <span class="n">to</span> <span class="n">generate</span> <span class="n">PaddlePaddle</span><span class="s1">&#39;s docs, default: disabled (OFF).</span>
<span class="o">**</span><span class="n">WITH_SWIG_PY</span><span class="o">**</span>    <span class="o">|</span> <span class="n">Compile</span> <span class="k">with</span> <span class="n">python</span> <span class="n">predict</span> <span class="n">API</span><span class="p">,</span> <span class="n">default</span><span class="p">:</span> <span class="n">disabled</span> <span class="p">(</span><span class="n">OFF</span><span class="p">)</span><span class="o">.</span>
<span class="o">**</span><span class="n">WITH_STYLE_CHECK</span><span class="o">**|</span> <span class="n">Compile</span> <span class="k">with</span> <span class="n">code</span> <span class="n">style</span> <span class="n">check</span><span class="p">,</span> <span class="n">default</span><span class="p">:</span> <span class="n">enabled</span> <span class="p">(</span><span class="n">ON</span><span class="p">)</span><span class="o">.</span>
</pre></div>
</div>
<p>|</p>
<p><strong>Note:</strong></p>
<ul class="simple">
<li>The GPU version works best with Cuda Toolkit 7.5 and cuDNN v5.</li>
<li>Other versions like Cuda Toolkit 6.5, 7.0, 8.0 and cuDNN v2, v3, v4 are also supported.</li>
<li><strong>To utilize cuDNN v5, Cuda Toolkit 7.5 is prerequisite and vice versa.</strong></li>
Y
Yu Yang 已提交
118
</ul>
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
<p>As a simple example, consider the following:</p>
<ol>
<li><p class="first"><strong>Python Dependencies(optional)</strong></p>
<p>To compile PaddlePaddle with python predict API, make sure swig installed and set <code class="docutils literal"><span class="pre">-DWITH_SWIG_PY=ON</span></code> as follows:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span><span class="c1"># install swig on ubuntu</span>
sudo apt-get install swig
<span class="c1"># install swig on Mac OS X</span>
brew install swig

<span class="c1"># active swig in cmake</span>
cmake .. -DWITH_SWIG_PY<span class="o">=</span>ON
</pre></div>
</div>
</li>
<li><p class="first"><strong>Doc Dependencies(optional)</strong></p>
<p>To generate PaddlePaddle&#8217;s documentation, install dependencies and set <code class="docutils literal"><span class="pre">-DWITH_DOC=ON</span></code> as follows:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>pip install <span class="s1">&#39;sphinx&gt;=1.4.0&#39;</span>
pip install sphinx_rtd_theme breathe recommonmark

<span class="c1"># install doxygen on Ubuntu</span>
sudo apt-get install doxygen 
<span class="c1"># install doxygen on Mac OS X</span>
brew install doxygen

<span class="c1"># active docs in cmake</span>
cmake .. -DWITH_DOC<span class="o">=</span>ON<span class="sb">`</span>
</pre></div>
</div>
</li>
</ol>
Y
Yu Yang 已提交
149 150
</div>
</div>
151 152
<div class="section" id="span-id-ubuntu-build-on-ubuntu-14-04-span">
<span id="span-id-ubuntu-build-on-ubuntu-14-04-span"></span><h2><span id="ubuntu">Build on Ubuntu 14.04</span><a class="headerlink" href="#span-id-ubuntu-build-on-ubuntu-14-04-span" title="Permalink to this headline"></a></h2>
Y
Yu Yang 已提交
153 154
<div class="section" id="install-dependencies">
<span id="install-dependencies"></span><h3>Install Dependencies<a class="headerlink" href="#install-dependencies" title="Permalink to this headline"></a></h3>
155 156
<ul>
<li><p class="first"><strong>CPU Dependencies</strong></p>
Y
Yu Yang 已提交
157 158
<div class="highlight-bash"><div class="highlight"><pre><span></span><span class="c1"># necessary</span>
sudo apt-get update
159
sudo apt-get install -y g++ make cmake build-essential libatlas-base-dev python python-pip libpython-dev m4 libprotobuf-dev protobuf-compiler python-protobuf python-numpy git
Y
Yu Yang 已提交
160 161 162 163
<span class="c1"># optional</span>
sudo apt-get install libgoogle-glog-dev
sudo apt-get install libgflags-dev
sudo apt-get install libgtest-dev
164
sudo pip install wheel
Y
Yu Yang 已提交
165 166 167 168 169 170 171
<span class="nb">pushd</span> /usr/src/gtest
cmake .
make
sudo cp *.a /usr/lib
<span class="nb">popd</span>
</pre></div>
</div>
172 173 174 175 176 177 178
</li>
<li><p class="first"><strong>GPU Dependencies (optional)</strong></p>
<p>To build GPU version, you will need the following installed:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>  <span class="mf">1.</span> <span class="n">a</span> <span class="n">CUDA</span><span class="o">-</span><span class="n">capable</span> <span class="n">GPU</span>
  <span class="mf">2.</span> <span class="n">A</span> <span class="n">supported</span> <span class="n">version</span> <span class="n">of</span> <span class="n">Linux</span> <span class="k">with</span> <span class="n">a</span> <span class="n">gcc</span> <span class="n">compiler</span> <span class="ow">and</span> <span class="n">toolchain</span>
  <span class="mf">3.</span> <span class="n">NVIDIA</span> <span class="n">CUDA</span> <span class="n">Toolkit</span> <span class="p">(</span><span class="n">available</span> <span class="n">at</span> <span class="n">http</span><span class="p">:</span><span class="o">//</span><span class="n">developer</span><span class="o">.</span><span class="n">nvidia</span><span class="o">.</span><span class="n">com</span><span class="o">/</span><span class="n">cuda</span><span class="o">-</span><span class="n">downloads</span><span class="p">)</span>
  <span class="mf">4.</span> <span class="n">NVIDIA</span> <span class="n">cuDNN</span> <span class="n">Library</span> <span class="p">(</span><span class="n">availabel</span> <span class="n">at</span> <span class="n">https</span><span class="p">:</span><span class="o">//</span><span class="n">developer</span><span class="o">.</span><span class="n">nvidia</span><span class="o">.</span><span class="n">com</span><span class="o">/</span><span class="n">cudnn</span><span class="p">)</span>
Y
Yu Yang 已提交
179 180
</pre></div>
</div>
181 182 183 184
<p>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.</p>
<p>After downloading cuDNN library, issue the following commands:</p>
Y
Yu Yang 已提交
185 186 187 188 189
<div class="highlight-bash"><div class="highlight"><pre><span></span>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*
</pre></div>
</div>
<p>Then you need to set LD_LIBRARY_PATH, CUDA_HOME and PATH environment variables in ~/.bashrc.</p>
Y
Yu Yang 已提交
190
<div class="highlight-bash"><div class="highlight"><pre><span></span><span class="nb">export</span> <span class="nv">LD_LIBRARY_PATH</span><span class="o">=</span>/usr/local/cuda/lib64:<span class="nv">$LD_LIBRARY_PATH</span>
Y
Yu Yang 已提交
191 192 193 194
<span class="nb">export</span> <span class="nv">CUDA_HOME</span><span class="o">=</span>/usr/local/cuda
<span class="nb">export</span> <span class="nv">PATH</span><span class="o">=</span>/usr/local/cuda/bin:<span class="nv">$PATH</span>
</pre></div>
</div>
195
</li>
Y
Yu Yang 已提交
196 197
</ul>
</div>
198 199 200 201 202
<div class="section" id="build-and-install">
<span id="build-and-install"></span><h3>Build and Install<a class="headerlink" href="#build-and-install" title="Permalink to this headline"></a></h3>
<p>As usual, the best option is to create build folder under paddle project directory.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>mkdir build <span class="o">&amp;&amp;</span> <span class="nb">cd</span> build
cmake ..
Y
Yu Yang 已提交
203 204
</pre></div>
</div>
205 206 207 208 209 210 211
<p>CMake first check PaddlePaddle&#8217;s dependencies in system default path. After installing some optional
libraries, corresponding build option will be set automatically (for instance, glog, gtest and gflags).
If still not found, you can manually set it based on CMake error information from your screen.</p>
<p>As a simple example, consider the following:</p>
<ul>
<li><p class="first"><strong>Only CPU</strong></p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>cmake  .. -DWITH_GPU<span class="o">=</span>OFF -DWITH_DOC<span class="o">=</span>OFF
Y
Yu Yang 已提交
212 213
</pre></div>
</div>
214 215 216
</li>
<li><p class="first"><strong>GPU</strong></p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>cmake .. -DWITH_GPU<span class="o">=</span>ON -DWITH_DOC<span class="o">=</span>OFF
Y
Yu Yang 已提交
217 218
</pre></div>
</div>
219 220 221
</li>
<li><p class="first"><strong>GPU with doc and swig</strong></p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>cmake .. -DWITH_GPU<span class="o">=</span>ON -DWITH_DOC<span class="o">=</span>ON -DWITH_SWIG_PY<span class="o">=</span>ON
Y
Yu Yang 已提交
222 223
</pre></div>
</div>
224 225
</li>
</ul>
Y
Yu Yang 已提交
226
<p>Finally, you can download source code and build:</p>
227 228
<div class="highlight-bash"><div class="highlight"><pre><span></span><span class="c1"># you can add build option here, such as:    </span>
cmake .. -DWITH_GPU<span class="o">=</span>ON -DWITH_DOC<span class="o">=</span>OFF -DCMAKE_INSTALL_PREFIX<span class="o">=</span>&lt;path to install&gt;
229 230
<span class="c1"># please use sudo make install, if you want</span>
<span class="c1"># to install PaddlePaddle into the system</span>
Y
Yu Yang 已提交
231
make -j <span class="sb">`</span>nproc<span class="sb">`</span> <span class="o">&amp;&amp;</span> make install
232
<span class="c1"># set PaddlePaddle installation path in ~/.bashrc</span>
Y
Yu Yang 已提交
233
<span class="nb">export</span> <span class="nv">PATH</span><span class="o">=</span>&lt;path to install&gt;/bin:<span class="nv">$PATH</span>
Y
Yu Yang 已提交
234 235
</pre></div>
</div>
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358
<p><strong>Note:</strong></p>
<p>If you set <code class="docutils literal"><span class="pre">WITH_SWIG_PY=ON</span></code>, related python dependencies also need to be installed.
Otherwise, PaddlePaddle will automatically install python dependencies
at first time when user run paddle commands, such as <code class="docutils literal"><span class="pre">paddle</span> <span class="pre">version</span></code>, <code class="docutils literal"><span class="pre">paddle</span> <span class="pre">train</span></code>.
It may require sudo privileges:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span><span class="c1"># you can run</span>
sudo pip install &lt;path to install&gt;/opt/paddle/share/wheels/*.whl
<span class="c1"># or just run </span>
sudo paddle version
</pre></div>
</div>
</div>
</div>
<div class="section" id="span-id-mac-building-on-mac-os-x-span">
<span id="span-id-mac-building-on-mac-os-x-span"></span><h2><span id="mac">Building on Mac OS X</span><a class="headerlink" href="#span-id-mac-building-on-mac-os-x-span" title="Permalink to this headline"></a></h2>
<div class="section" id="prerequisites">
<span id="prerequisites"></span><h3>Prerequisites<a class="headerlink" href="#prerequisites" title="Permalink to this headline"></a></h3>
<p>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,
you will already have Python 2.7.10 and Numpy 1.8 installed.</p>
<p>The best option is to use the package manager homebrew to handle installations and upgrades for you.
To install <a class="reference external" href="http://brew.sh/">homebrew</a>, first open a terminal window (you can find Terminal in the Utilities folder in Applications), and issue the command:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span><span class="c1"># install brew</span>
/usr/bin/ruby -e <span class="s2">&quot;</span><span class="k">$(</span>curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install<span class="k">)</span><span class="s2">&quot;</span>
<span class="c1"># install pip</span>
easy_install pip
</pre></div>
</div>
</div>
<div class="section" id="install-dependencies">
<span id="id1"></span><h3>Install Dependencies<a class="headerlink" href="#install-dependencies" title="Permalink to this headline"></a></h3>
<ul>
<li><p class="first"><strong>CPU Dependencies</strong></p>
<div class="highlight-bash"><div class="highlight"><pre><span></span><span class="c1"># Install fundamental dependents </span>
brew install glog gflags cmake protobuf openblas

<span class="c1"># Install google test on Mac OS X</span>
<span class="c1"># Download gtest 1.7.0</span>
wget https://github.com/google/googletest/archive/release-1.7.0.tar.gz
tar -xvf googletest-release-1.7.0.tar.gz <span class="o">&amp;&amp;</span> <span class="nb">cd</span> googletest-release-1.7.0
<span class="c1"># Build gtest</span>
mkdir build <span class="o">&amp;&amp;</span> cmake ..
make
<span class="c1"># Install gtest library</span>
sudo cp -r ../include/gtest /usr/local/include/
sudo cp lib*.a /usr/local/lib
</pre></div>
</div>
</li>
<li><p class="first"><strong>GPU Dependencies(optional)</strong></p>
<p>To build GPU version, you will need the following installed:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>  <span class="mf">1.</span> <span class="n">a</span> <span class="n">CUDA</span><span class="o">-</span><span class="n">capable</span> <span class="n">GPU</span>
  <span class="mf">2.</span> <span class="n">Mac</span> <span class="n">OS</span> <span class="n">X</span> <span class="mf">10.11</span> <span class="ow">or</span> <span class="n">later</span>
  <span class="mf">2.</span> <span class="n">the</span> <span class="n">Clang</span> <span class="n">compiler</span> <span class="ow">and</span> <span class="n">toolchain</span> <span class="n">installed</span> <span class="n">using</span> <span class="n">Xcode</span>
  <span class="mf">3.</span> <span class="n">NVIDIA</span> <span class="n">CUDA</span> <span class="n">Toolkit</span> <span class="p">(</span><span class="n">available</span> <span class="n">at</span> <span class="n">http</span><span class="p">:</span><span class="o">//</span><span class="n">developer</span><span class="o">.</span><span class="n">nvidia</span><span class="o">.</span><span class="n">com</span><span class="o">/</span><span class="n">cuda</span><span class="o">-</span><span class="n">downloads</span><span class="p">)</span>
  <span class="mf">4.</span> <span class="n">NVIDIA</span> <span class="n">cuDNN</span> <span class="n">Library</span> <span class="p">(</span><span class="n">availabel</span> <span class="n">at</span> <span class="n">https</span><span class="p">:</span><span class="o">//</span><span class="n">developer</span><span class="o">.</span><span class="n">nvidia</span><span class="o">.</span><span class="n">com</span><span class="o">/</span><span class="n">cudnn</span><span class="p">)</span>
</pre></div>
</div>
<p>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.</p>
<ol>
<li><p class="first">After downloading cuDNN library, issue the following commands:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>sudo tar -xzf cudnn-7.5-osx-x64-v5.0-ga.tgz -C /usr/local
sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*
</pre></div>
</div>
</li>
<li><p class="first">Then you need to set DYLD_LIBRARY_PATH, CUDA_HOME and PATH environment variables in ~/.bashrc.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span><span class="nb">export</span> <span class="nv">DYLD_LIBRARY_PATH</span><span class="o">=</span>/usr/local/cuda/lib:<span class="nv">$DYLD_LIBRARY_PATH</span>
<span class="nb">export</span> <span class="nv">PATH</span><span class="o">=</span>/usr/local/cuda/bin:<span class="nv">$PATH</span>
</pre></div>
</div>
</li>
</ol>
</li>
</ul>
</div>
<div class="section" id="build-and-install">
<span id="id2"></span><h3>Build and Install<a class="headerlink" href="#build-and-install" title="Permalink to this headline"></a></h3>
<p>As usual, the best option is to create build folder under paddle project directory.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>mkdir build <span class="o">&amp;&amp;</span> <span class="nb">cd</span> build
cmake ..
</pre></div>
</div>
<p>CMake first check PaddlePaddle&#8217;s dependencies in system default path. After installing some optional
libraries, corresponding build option will be set automatically (for instance, glog, gtest and gflags).
If still not found, you can manually set it based on CMake error information from your screen.</p>
<p>As a simple example, consider the following:</p>
<ul>
<li><p class="first"><strong>Only CPU</strong></p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>cmake  .. -DWITH_GPU<span class="o">=</span>OFF -DWITH_DOC<span class="o">=</span>OFF
</pre></div>
</div>
</li>
<li><p class="first"><strong>GPU</strong></p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>cmake .. -DWITH_GPU<span class="o">=</span>ON -DWITH_DOC<span class="o">=</span>OFF
</pre></div>
</div>
</li>
<li><p class="first"><strong>GPU with doc and swig</strong></p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>cmake .. -DWITH_GPU<span class="o">=</span>ON -DWITH_DOC<span class="o">=</span>ON -DWITH_SWIG_PY<span class="o">=</span>ON
</pre></div>
</div>
</li>
</ul>
<p>Finally, you can build PaddlePaddle:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span><span class="c1"># you can add build option here, such as:    </span>
cmake .. -DWITH_GPU<span class="o">=</span>ON -DWITH_DOC<span class="o">=</span>OFF -DCMAKE_INSTALL_PREFIX<span class="o">=</span>&lt;installation path&gt;
<span class="c1"># please use sudo make install, if you want to install PaddlePaddle into the system</span>
make -j <span class="sb">`</span>nproc<span class="sb">`</span> <span class="o">&amp;&amp;</span> make install
<span class="c1"># set PaddlePaddle installation path in ~/.bashrc</span>
<span class="nb">export</span> <span class="nv">PATH</span><span class="o">=</span>&lt;installation path&gt;/bin:<span class="nv">$PATH</span>
</pre></div>
</div>
<p><strong>Note:</strong></p>
<p>If you set <code class="docutils literal"><span class="pre">WITH_SWIG_PY=ON</span></code>, related python dependencies also need to be installed.
Otherwise, PaddlePaddle will automatically install python dependencies
at first time when user run paddle commands, such as <code class="docutils literal"><span class="pre">paddle</span> <span class="pre">version</span></code>, <code class="docutils literal"><span class="pre">paddle</span> <span class="pre">train</span></code>.
It may require sudo privileges:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span><span class="c1"># you can run</span>
sudo pip install &lt;path to install&gt;/opt/paddle/share/wheels/*.whl
<span class="c1"># or just run </span>
sudo paddle version
Y
Yu Yang 已提交
359 360 361 362 363 364 365 366 367 368 369 370 371 372
</pre></div>
</div>
</div>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../index.html">Table Of Contents</a></h3>
  <ul>
373 374 375 376 377 378 379 380 381 382
<li><a class="reference internal" href="#">Installing from Sources</a><ul>
<li><a class="reference internal" href="#span-id-download-download-and-setup-span"><span id="download">Download and Setup</span></a></li>
<li><a class="reference internal" href="#span-id-requirements-requirements-span"><span id="requirements">Requirements</span></a><ul>
<li><a class="reference internal" href="#dependencies">Dependencies</a></li>
<li><a class="reference internal" href="#options">Options</a></li>
</ul>
</li>
<li><a class="reference internal" href="#span-id-ubuntu-build-on-ubuntu-14-04-span"><span id="ubuntu">Build on Ubuntu 14.04</span></a><ul>
<li><a class="reference internal" href="#install-dependencies">Install Dependencies</a></li>
<li><a class="reference internal" href="#build-and-install">Build and Install</a></li>
Y
Yu Yang 已提交
383 384
</ul>
</li>
385 386
<li><a class="reference internal" href="#span-id-mac-building-on-mac-os-x-span"><span id="mac">Building on Mac OS X</span></a><ul>
<li><a class="reference internal" href="#prerequisites">Prerequisites</a></li>
Y
Yu Yang 已提交
387
<li><a class="reference internal" href="#install-dependencies">Install Dependencies</a></li>
Y
Yu Yang 已提交
388
<li><a class="reference internal" href="#build-and-install">Build and Install</a></li>
Y
Yu Yang 已提交
389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410
</ul>
</li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="index.html"
                        title="previous chapter">Build And Install PaddlePaddle</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="contribute_to_paddle.html"
                        title="next chapter">Contribute to PaddlePaddle</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../_sources/build/build_from_source.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3>Quick search</h3>
    <form class="search" action="../search.html" method="get">
411 412
      <div><input type="text" name="q" /></div>
      <div><input type="submit" value="Go" /></div>
Y
Yu Yang 已提交
413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="contribute_to_paddle.html" title="Contribute to PaddlePaddle"
             >next</a> |</li>
        <li class="right" >
          <a href="index.html" title="Build And Install PaddlePaddle"
             >previous</a> |</li>
437 438
        <li class="nav-item nav-item-0"><a href="../index.html">PaddlePaddle  documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="index.html" >Build And Install PaddlePaddle</a> &#187;</li> 
Y
Yu Yang 已提交
439 440 441
      </ul>
    </div>
    <div class="footer" role="contentinfo">
442 443
        &#169; Copyright 2016, PaddlePaddle developers.
      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.4.6.
Y
Yu Yang 已提交
444 445 446
    </div>
  </body>
</html>