Compile on Windows from Source Code¶
Windows 7/8/10 Pro/Enterprise(64bit)
GPU Version support CUDA 10.1/10.2/11.1/11.2/11.6/11.7, and only support single GPU
Python version 3.6+/3.7+/3.8+/3.9+/3.10+(64bit)
pip version 20.2.2 or above (64bit)
Visual Studio 2017
If your computer doesn’t have NVIDIA® GPU, please install CPU version of PaddlePaddle
If your computer has NVIDIA® GPU, and the following conditions are met，GPU version of PaddlePaddle is recommended.
CUDA toolkit 10.1/10.2 with cuDNN v7.6.5
CUDA toolkit 11.1 with cuDNN v8.1.1
CUDA toolkit 11.2 with cuDNN v8.2.1
CUDA toolkit 11.6 with cuDNN v8.4.0
CUDA toolkit 11.7 with cuDNN v8.4.1
GPU’s computing capability exceeds 3.5
There is one compilation methods in Windows system:
Direct native source code compilation(NCCL, distribution are not supported on windows now)
Direct native source code compilation¶
Please strictly follow the following instructions step by step
Install the necessary tools i.e. cmake, git and python:
CMake requires version 3.15 and above, but there are official Bug versions of 3.12/3.13/3.14 when the GPU is compiled, we recommend that you use CMake3. 16 version, available on the official website [download] (https://cmake.org/download/), and add to the ring Environment variables.
Python requires version 3.6 and above, which can be downloaded from the official website.
After installing python, please check whether the python version is the expected version by
python-version, because you may have more than one python installed on your computer. You can handle conflicts of multiple pythons by changing the order of the environment variables.
numpy, protobuf, wheelare needed to be installed. Use the ‘pip’ command.
To Install numpy package you can use command
pip install numpy
To Install protobuf package you can use command
pip install protobuf
To Install Wheel package you can use command
pip install wheel
Git can be downloaded on the official website and added to the environment variable.
Clone the PaddlePaddle source code to the Paddle subdirectories of the current directory and go to the Paddle subdirectories:
git clone https://github.com/PaddlePaddle/Paddle.git cd Paddle
Switch to a more stable release branch for compilation:
git checkout [name of the branch]
git checkout release/2.4
Note: python3.6、python3.7 version started supporting from release/1.2, python3.8 version started supporting from release/1.8, python3.9 version started supporting from release/2.1, python3.10 version started supporting from release/2.3
Create a directory called build and enter it:
mkdir build cd build
For details on the compilation options, see the compilation options list. On Windows, you can compile by
Visual Studio IDE, as follow:
Firstly, install ninja:
pip install ninja
Then, search “x64 Native Tools Command Prompt for VS” in Windows search bar, run it as Administrator. Here is the cmake command:
cmake .. -GNinja -DWITH_GPU=OFF
Visual Studio IDEmethod:
cmake .. -G "Visual Studio 15 2017" -A x64 -T host=x64 -DWITH_GPU=OFF
In the above command, change to
-DWITH_GPU=ONto compile the GPU version Paddle.
If more than one CUDA are installed, the latest installed CUDA will be used, and you can’t specify CUDA version.
If more than one Python are installed, the latest installed Python will be used by default, and you can choose the Python version by
-DPYTHON_EXECUTABLE. for example:
cmake .. -GNinja -DWITH_GPU=ON -DPYTHON_EXECUTABLE=C:\\Python36\\python.exe
ninja all, it will begin to compile.
Visual Studio IDEmethod, use Visual Studio to open
paddle.slnfile, select the platform
x64, configure with
Release, click the button, it will begin to compile.
After compilation successfully, go to the
\paddle\build\python\distdirectory and find the generated
Install the generated
pip install -U (whl package name)
Congratulations, you have completed the process of compiling PaddlePaddle successfully!
After the compilation and installation is completed, you can use
python to enter the Python interface, input
to verify that the installation was successful.
PaddlePaddle is installed successfully! appears, it means the compilation and installation was successful.
How to uninstall¶
Please use the following command to uninstall PaddlePaddle:
CPU version of PaddlePaddle :
pip uninstall paddlepaddle
GPU version of PaddlePaddle :
pip uninstall paddlepaddle-gpu