compile_Windows_en.md 5.5 KB
Newer Older
1
***
2
# **Compile on Windows from Source Code**
3 4 5 6 7 8 9 10

This instruction will show you how to compile PaddlePaddle on a *64-bit desktop or laptop* and Windows 10. The Windows systems we support must meet the following requirements:

* Windows 10 Family Edition / Professional Edition / Enterprise Edition
* Visual Studio 2015 Update3

## Determine which version to compile

A
acosta123 已提交
11
* 1.3 version PaddlePaddle can support GPU. In order to make PaddlePaddle programs run faster, we usually use GPU to accelerate them. However, for the installation of GPU version of PaddlePaddle, NVIDIA GPU which satisfies with the following condictions is needed(please refer to the offical document of NVIDIA GPU for more installation and configuration details: [For CUDA](https://docs.nvidia.com/cuda/cuda-installation-guide-linux/)[For cuDNN](https://docs.nvidia.com/deeplearning/sdk/cudnn-install/)
A
acosta123 已提交
12 13
* Cuda tool package8.0 with cuDNN v7
* Hardware device with GPU calculation performance beyond 1.0
14 15 16 17 18 19 20 21 22

## Choose a compilation method

We provide one compilation method under the Windows system:

* Direct source code compilation

Since the situation on host machine is more complicated, we only support specific systems.

A
acosta123 已提交
23
Please note: The current version does not support NCCL, distributed related functions.
24 25 26 27 28 29 30 31 32 33 34 35 36 37


### ***Local compilation***

**Please strictly follow the following instructions step by step**

1. Check that your computer and operating system meet our supported compilation standards

	* Windows 10 Family Edition / Professional Edition / Enterprise Edition

	* Visual Studio 2015 Update3

2. Install the necessary tools i.e. cmake, git and python :

A
acosta123 已提交
38
	> Cmake requires version 3.5 and above, which can be downloaded from the official website and added to the environment variable. [Download here](https://cmake.org/download/).
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56

	> Git can be downloaded on the official website and added to the environment variable. [Download here](https://gitforwindows.org/).

	> Python requires version 2.7 and above, and ensure that modules such as numpy, protobuf, wheel are installed. [Download here](https://www.python.org/download/releases/2.7/).


		* To Install numpy package you can use command `pip install numpy` or command `pip3 install numpy`

		* To Install protobuf package you can use command `pip install protobuf` or command `pip3 install protobuf`

		* To Install Wheel package you can use command `pip install wheel` or `pip3 install wheel`


3. Clone the PaddlePaddle source in the Paddle folder in the current directory and go to the Paddle directory:

	- `git clone https://github.com/PaddlePaddle/Paddle.git`
	- `cd Paddle`

57
4. Switch to a more stable release branch for compilation :
58

A
acosta123 已提交
59
	- `git checkout release/1.3`
60 61 62 63 64 65 66 67 68 69

5. Create a directory called build and enter it:

	- `mkdir build`
	- `cd build`

6. Execute cmake:

	> For details on the compilation options, see [the compilation options list](../Tables.html/#Compile).

A
acosta123 已提交
70
	* For users who need to compile **CPU version of PaddlePaddle**:
71 72 73 74 75 76 77 78 79 80

		For Python2:`cmake .. -G "Visual Studio 14 2015 Win64" -DPYTHON_INCLUDE_DIR = $ {PYTHON_INCLUDE_DIRS} 
			-DPYTHON_LIBRARY = $ {PYTHON_LIBRARY} 
			-DPYTHON_EXECUTABLE = $ {PYTHON_EXECUTABLE} -DWITH_FLUID_ONLY = ON -DWITH_GPU = OFF -DWITH_TESTING = OFF -DCMAKE_BUILD_TYPE =Release`


		For Python3: `cmake .. -G "Visual Studio 14 2015 Win64" -DPY_VERSION = 3.5 -DPYTHON_INCLUDE_DIR = $ {PYTHON_INCLUDE_DIRS} 
			-DPYTHON_LIBRARY = $ {PYTHON_LIBRARY} 
			-DPYTHON_EXECUTABLE = $ {PYTHON_EXECUTABLE} -DWITH_FLUID_ONLY = ON -DWITH_GPU = OFF -DWITH_TESTING =OFF -DCMAKE_BUILD_TYPE=Release`

A
acosta123 已提交
81 82 83 84 85 86 87 88 89 90 91
			*  For users who need to compile **GPU version PaddlePaddle**:

  		For Python2: `cmake .. -G "Visual Studio 14 2015 Win64" -DPYTHON_INCLUDE_DIR=${PYTHON_INCLUDE_DIRS}
 			 -DPYTHON_LIBRARY=${PYTHON_LIBRARY}
 			 -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}
 			 -DWITH_FLUID_ONLY=ON -DWITH_GPU=ON -DWITH_TESTING=OFF -DCMAKE_BUILD_TYPE=Release -DCUDA_TOOLKIT_ROOT_DIR=${CUDA_TOOLKIT_ROOT_DIR}`

  		For Python3: `cmake .. -G "Visual Studio 14 2015 Win64" -DPY_VERSION=3.5 -DPYTHON_INCLUDE_DIR=${PYTHON_INCLUDE_DIRS}
 			 -DPYTHON_LIBRARY=${PYTHON_LIBRARY}
 			 -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}
 			 -DWITH_FLUID_ONLY=ON -DWITH_GPU=ON -DWITH_TESTING=OFF -DCMAKE_BUILD_TYPE=Release -DCUDA_TOOLKIT_ROOT_DIR=${CUDA_TOOLKIT_ROOT_DIR}`
92 93 94

7. Some third-party dependencies (openblas, snappystream) currently require users to provide pre-compiled versions, or download pre-compiled files from `https://github.com/wopeizl/Paddle_deps` and place the entire `third_party` folder in the `build` directory. 

A
acosta123 已提交
95
8. Use Blend for Visual Studio 2015 to open `paddle.sln` file, select the platform `x64`, configure with `Release`, compile the third_party module and then other modules
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116

9. Having compiled successfully, go to the `\paddle\build\python\dist`directory and find the generated `.whl` package:

	`cd \paddle\build\python\dist`

10. Install the compiled `.whl` package on the current machine or target machine:

 	`pip install (whl package name)` or `pip3 install (whl package name)`

Congratulations, now you have completed the process of compiling PaddlePaddle natively.


### ***Verify installation***

After the installation is complete, you can use: `python` to enter the Python interpreter and then use `import paddle.fluid`. If there is no error prompted, the installation is successful.

### ***How to uninstall***

Please use the following command to uninstall PaddlePaddle:

* ***CPU version of PaddlePaddle*** : `pip uninstall paddlepaddle` or `pip3 uninstall paddlepaddle`
A
acosta123 已提交
117 118

* ***GPU version of PaddlePaddle***: `pip uninstall paddlepaddle-gpu``pip3 uninstall paddlepaddle-gpu`