Compile on Windows from Source Code¶
Windows 7/8/10 Pro/Enterprise(64bit)
GPU Version support CUDA 11.0 - 12.0, and only support single GPU
Python version 3.8+/3.9+/3.10+/3.11+/3.12+(64bit)
pip version 20.2.2 or above (64bit)
Visual Studio 2017(for CPU)/2019(for GPU)
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. Suggested installation CUDA 11.0/11.2/11.6/11.8/12.0
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.17 and above, and add to the ring Environment variables.
Python requires version 3.8 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
developbranch for compilation:
git checkout develop
Note: Paddle supports Python version 3.8 and above.
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 -DWITH_UNITY_BUILD=ON
Visual Studio IDEmethod:
cmake .. -G "Visual Studio 15 2017" -A x64 -T host=x64 -DWITH_GPU=OFF -DWITH_UNITY_BUILD=ON
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. If you need to specify a CUDA version, you’ll need to set environment variables and CMake options. for example:
set CUDA_TOOLKIT_ROOT_DIR=C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.2 set PATH=%CUDA_TOOLKIT_ROOT_DIR:/=\%\bin;%CUDA_TOOLKIT_ROOT_DIR:/=\%\libnvvp;%PATH% cmake .. -GNinja -DWITH_GPU=ON -DCUDA_TOOLKIT_ROOT_DIR="%CUDA_TOOLKIT_ROOT_DIR%" -DWITH_UNITY_BUILD=ON
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:\\Python38\\python.exe -DWITH_UNITY_BUILD=ON
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