Compile on Windows from Source Code
Environment preparation
Windows 7/8/10 Pro/Enterprise(64bit)
GPU Version support CUDA 11.0 - 12.0, and only support single GPU
Python version 3.9+/3.10+/3.11+/3.12+/3.13+ (64bit)
pip version 20.2.2 or above (64bit)
Visual Studio 2017(for CPU)/2019(for GPU)
Choose CPU/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
Installation steps
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.9 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.
Install compilation dependencies
pip install -r /paddle/python/requirements.txtGit 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
developbranch for compilation:git checkout develop
Note: Paddle supports Python version 3.9 and above.
Create a directory called build and enter it:
mkdir build cd build
Execute cmake:
For details on the compilation options, see the compilation options list. On Windows, you can compile by
Ninja(recommended)orVisual Studio IDE, as follow:1)Compile by
Ninja(recommended)method: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
2)Compile by
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.Note:
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 -DWITH_DISTRIBUTE=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 -DWITH_DISTRIBUTE=ON
Execute compile:
-
For
Ninjamethod(recommended), runninja all, it will begin to compile.
-
For
Visual Studio IDEmethod, use Visual Studio to openpaddle.slnfile, select the platformx64, configure withRelease, click the button, it will begin to compile.
-
After compilation successfully, go to the
\paddle\build\python\distdirectory and find the generated.whlpackage:cd \paddle\build\python\dist
Install the generated
.whlpackage:pip install -U (whl package name)
Congratulations, you have completed the process of compiling PaddlePaddle successfully!
Verify installation
After the compilation and installation is completed, you can use python to enter the Python interface, input
import paddle
and then
paddle.utils.run_check()
to verify that the installation was successful.
If 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
