The compilation and installation of Paddle2ONNX require ensuring that the environment meets the following requirements:
- cmake >= 3.16.0
- protobuf == 21.12
git clone https://github.com/protocolbuffers/protobuf.git
cd protobuf
git checkout v21.12
git submodule update --init
mkdir build_source && cd build_source
cmake ../cmake -DCMAKE_INSTALL_PREFIX=`pwd`/installed_protobuf_lib -Dprotobuf_BUILD_SHARED_LIBS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=14
make -j
make install
# set the library to environment
export PATH=${PWD}/installed_protobuf_lib/bin:${PATH}Install Protobuf via apt (Linux):
sudo apt install protobuf-compilerInstall Protobuf via homebrew (Mac):
brew install protobufpython -m pip install --pre paddlepaddle -i https://www.paddlepaddle.org.cn/packages/nightly/cpu/git clone https://github.com/PaddlePaddle/Paddle2ONNX.git
cd Paddle2ONNX
git submodule update --init
export PIP_EXTRA_INDEX_URL="https://www.paddlepaddle.org.cn/packages/nightly/cpu/"
python -m build
pip install dist/*.whlIf you are developing the Paddle2ONNX project locally, you can use pip install -e . to install it in editable mode.
Note that the prerequisite for compiling and installing Windows is that Visual Studio 2019 is already installed in the system
- Download Visual Studio 16 2019 from this link and run
vs_community.exe. - Under the Workloads tab, select the checkbox for Desktop development with C++.
- Note: Under Installation Details > Desktop Development with C++ > Optional: Live Share and Intellicode are unnecessary, feel free to uncheck these boxes.
- Click Install
In the system menu, find x64 Native Tools Command Prompt for VS 2019 and open it.
Note that the -DCMAKE_INSTALL_PREFIX in the following cmake command specifies your actual set path.
git clone https://github.com/protocolbuffers/protobuf.git
cd protobuf
git checkout v21.12
git submodule update --init --recursive
mkdir build
cd build
cmake -G "Visual Studio 16 2019" -DCMAKE_INSTALL_PREFIX=%CD%\protobuf_install -Dprotobuf_MSVC_STATIC_RUNTIME=OFF -Dprotobuf_BUILD_SHARED_LIBS=OFF -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_EXAMPLES=OFF ..
cmake --build . --config Release --target install
# set the library to environment
set PATH=%CD%\protobuf_install\bin;%PATH%git clone https://github.com/PaddlePaddle/Paddle2ONNX.git
cd Paddle2ONNX
git submodule update --init
set PIP_EXTRA_INDEX_URL=https://www.paddlepaddle.org.cn/packages/nightly/cpu/
pip install setuptools wheel auditwheel auditwheel-symbols build
python -m build
pip install dist/*.whl