Compile From Source Code¶
You can also choose to compile and install PaddlePaddle in the way of source code compilation. However, due to the diversity of the native environment, complicated problems may occur when compiling the source code, which may cause your installation to fail. In order to ensure your smooth installation, it is recommended that you prefer the normal installation method.
- Compile on Linux from Source Code
- Environment preparation
- Choose CPU/GPU
- Installation steps
- Compile with Docker
- 1. First select the path where you want to store PaddlePaddle, then use the following command to clone PaddlePaddle’s source code from github to a folder named Paddle in the local current directory:
- 2. Go to the Paddle directory:
- 3. Pull PaddlePaddle image:
- 4. Create and enter a Docker container that meets the compilation environment:
- 5. After entering Docker, go to the paddle directory:
- 6. Switch to develop version to compile:
- 7. Create and enter the /paddle/build path:
- 8. Use the following command to install the dependencies:
- 9. Execute cmake:
- 10. Execute compilation:
- 11. After compiling successfully, go to the
/paddle/build/python/dist
directory and find the generated.whl
package: - 12. Install the compiled
.whl
package on the current machine or target machine: - Congratulations, now that you have successfully installed PaddlePaddle using Docker, you only need to run PaddlePaddle after entering the Docker container. For more Docker usage, please refer to the official Docker documentation.
- Local compilation
- 1. Check that your computer and operating system meet the compilation standards we support:
- 2. Update the system source
- 3. Install NCCL (optional)
- 4. Install the necessary tools
- 5. We support compiling and installing with virtualenv. First, create a virtual environment called
paddle-venv
with the following command: - 6. Enter the virtual environment:
- 7. Before executing the compilation, please confirm that the related dependencies mentioned in the compile dependency table are installed in the virtual environment:
- 8. Put the PaddlePaddle source cloned in the Paddle folder in the current directory and go to the Paddle directory:
- 9. Switch to develop branch for compilation (Paddle supports Python version 3.8 and above):
- 10. And please create and enter a directory called build:
- 11. Execute cmake:
- 12. Compile with the following command:
- 13. After compiling successfully, go to the
/paddle/build/python/dist
directory and find the generated.whl
package: - 14. Install the compiled
.whl
package on the current machine or target machine: - Congratulations, now you have completed the process of compiling PaddlePaddle natively.
- Verify installation
- How to uninstall
- Compile with Docker
- Compile on macOS from Source Code
- Environment preparation
- Choose CPU/GPU
- Installation steps
- Compile with Docker
- 1. Enter the terminal of the Mac
- 2. Please select the path where you want to store PaddlePaddle, and then use the following command to clone PaddlePaddle’s source code from github to a folder named Paddle in the local current directory:
- 3. Go to the Paddle directory:
- 4. Pull PaddlePaddle image
- 5. Create and enter a Docker container that meets the compilation environment:
- 6. After entering Docker, go to the paddle directory:
- 7. Switch to develop version to compile:
- 8. Create and enter the /paddle/build path:
- 9. Use the following command to install the dependencies:
- 10. Execute cmake:
- 11. Execute compilation:
- 12. After compiling successfully, go to the
/paddle/build/python/dist
directory and find the generated.whl
package: - 13. Install the compiled
.whl
package on the current machine or target machine: (For Python3: Please select the pip corresponding to the python version you wish to use, such as pip3.10) - Congratulations, now that you have successfully installed PaddlePaddle using Docker, you only need to run PaddlePaddle after entering the Docker container. For more Docker usage, please refer to the official Docker documentation.
- Local compilation
- 1. Check that your computer and operating system meet our supported compilation standards:
uname -m
and view the system versionabout this Mac
. And install OpenCV in advance. - 2. Install python and pip:
- 3. (Only For Python3) Set Python-related environment variables:
- 4. Before compilation, please confirm that the relevant dependencies mentioned in the compilation dependency table are installed in your environment, otherwise we strongly recommend using
Homebrew
to install related dependencies. - 5. Put the PaddlePaddle source cloned in the Paddle folder in the current directory and go to the Paddle directory:
- 6. Switch to develop branch to compile: (Paddle supports Python version 3.8 and above)
- 7. And please create and enter a directory called build:
- 8. Execute cmake:
- 9. Compile with the following command:
- 10. After compiling successfully, go to the
/paddle/build/python/dist
directory and find the generated.whl
package: - 11. Install the compiled
.whl
package on the current machine or target machine: - Congratulations, now you have completed the process of compiling PaddlePaddle using this machine.
- 1. Check that your computer and operating system meet our supported compilation standards:
- Verify installation
- How to uninstall
- Compile with Docker
- Compile on Windows from Source Code