Skip to content

Commit 31f0fd6

Browse files
askhadegramalingam
andauthored
update protobuf build options and build instructions (onnx#3550)
* update protobuf build options and build instructions Signed-off-by: Ashwini Khade <[email protected]> * update readme Signed-off-by: Ashwini Khade <[email protected]> * plus updates per review Signed-off-by: Ashwini Khade <[email protected]> * plus a few more Signed-off-by: Ashwini Khade <[email protected]> * fix typo Signed-off-by: Ashwini Khade <[email protected]> Co-authored-by: G. Ramalingam <[email protected]>
1 parent 6c77a41 commit 31f0fd6

File tree

9 files changed

+80
-97
lines changed

9 files changed

+80
-97
lines changed

.azure-pipelines/Linux-CI.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
git submodule update --init --recursive
5252
mkdir build_source && cd build_source
5353
54-
cmake ../cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_SYSCONFDIR=/etc -DCMAKE_POSITION_INDEPENDENT_CODE=ON -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release
54+
cmake ../cmake -Dprotobuf_BUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_SYSCONFDIR=/etc -DCMAKE_POSITION_INDEPENDENT_CODE=ON -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release
5555
make -j$(nproc)
5656
sudo make install
5757
cd ../..

.azure-pipelines/Windows-CI.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
set ONNX_ML=$(onnx_ml)
5252
set ONNX_VERIFY_PROTO_3=$(onnx_verify_proto)
5353
set USE_MSVC_STATIC_RUNTIME=0
54-
set CMAKE_ARGS=-DONNX_USE_PROTOBUF_SHARED_LIBS=ON -DProtobuf_USE_STATIC_LIBS=OFF -DONNX_USE_LITE_PROTO=ON -DONNX_WERROR=ON
54+
set CMAKE_ARGS=-DONNX_USE_PROTOBUF_SHARED_LIBS=ON -DONNX_USE_LITE_PROTO=ON -DONNX_WERROR=ON
5555
5656
python setup.py --quiet install
5757
pytest

.github/workflows/manylinux/entrypoint.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ git checkout v3.11.3
2424
git submodule update --init --recursive
2525
mkdir build_source && cd build_source
2626

27-
cmake ../cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_SYSCONFDIR=/etc -DCMAKE_POSITION_INDEPENDENT_CODE=ON -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release
27+
cmake ../cmake -Dprotobuf_BUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_SYSCONFDIR=/etc -DCMAKE_POSITION_INDEPENDENT_CODE=ON -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release
2828
make -j$(nproc)
2929
make install
3030
cd $ONNX_PATH

.github/workflows/release_win.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
- name: Install python dependencies
6060
run: |
6161
python -m pip install --upgrade pip
62-
python -m pip install numpy==1.16.6 wheel
62+
python -m pip install numpy==1.16.6 wheel
6363
6464
- name: Build ONNX wheel
6565
run: |
@@ -73,7 +73,7 @@ jobs:
7373
mkdir protobuf_install
7474
cd ./protobuf/cmake
7575
76-
cmake -G "Visual Studio 16 2019" -A $arch -DCMAKE_INSTALL_PREFIX="../../protobuf_install" -DCMAKE_BUILD_TYPE=Release -Dprotobuf_MSVC_STATIC_RUNTIME=ON -DProtobuf_USE_STATIC_LIBS=ON -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_EXAMPLES=OFF .
76+
cmake -G "Visual Studio 16 2019" -A $arch -DCMAKE_INSTALL_PREFIX="../../protobuf_install" -Dprotobuf_MSVC_STATIC_RUNTIME=ON -Dprotobuf_BUILD_SHARED_LIBS=OFF -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_EXAMPLES=OFF .
7777
msbuild protobuf.sln /m /p:Configuration=Release
7878
msbuild INSTALL.vcxproj /p:Configuration=Release
7979
echo "Protobuf installation complete."
@@ -91,7 +91,7 @@ jobs:
9191
echo "Install ONNX"
9292
$Env:USE_MSVC_STATIC_RUNTIME=1
9393
$Env:ONNX_ML=1
94-
$Env:CMAKE_ARGS="-DONNX_USE_PROTOBUF_SHARED_LIBS=OFF -DProtobuf_USE_STATIC_LIBS=ON -DONNX_USE_LITE_PROTO=ON"
94+
$Env:CMAKE_ARGS="-DONNX_USE_PROTOBUF_SHARED_LIBS=OFF -DONNX_USE_LITE_PROTO=ON"
9595
9696
if ('${{ github.event_name }}' -eq 'schedule') {
9797
echo "Build weekly TestPyPI package"

.github/workflows/weekly_mac_ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
tar -xvf protobuf-cpp-3.11.3.tar.gz
5050
cd protobuf-3.11.3
5151
mkdir build_source && cd build_source
52-
cmake ../cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release
52+
cmake ../cmake -Dprotobuf_BUILD_SHARED_LIBS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release
5353
make -j${NUM_CORES}
5454
make install
5555
export PATH=$(pwd)/bin:$PATH

.github/workflows/win_no_exception_ci.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
mkdir protobuf_install
6363
cd ./protobuf/cmake
6464
65-
cmake -G "Visual Studio 16 2019" -A $arch -DCMAKE_INSTALL_PREFIX="../../protobuf_install" -DCMAKE_BUILD_TYPE=Release -Dprotobuf_MSVC_STATIC_RUNTIME=ON -DProtobuf_USE_STATIC_LIBS=ON -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_EXAMPLES=OFF .
65+
cmake -G "Visual Studio 16 2019" -A $arch -DCMAKE_INSTALL_PREFIX="../../protobuf_install" -Dprotobuf_MSVC_STATIC_RUNTIME=ON -Dprotobuf_BUILD_SHARED_LIBS=OFF -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_EXAMPLES=OFF .
6666
msbuild protobuf.sln /m /p:Configuration=Release
6767
msbuild INSTALL.vcxproj /p:Configuration=Release
6868
echo "Protobuf installation complete."
@@ -76,7 +76,7 @@ jobs:
7676
cd ../../../onnx
7777
7878
echo "Build ONNX"
79-
cmake -G "Visual Studio 16 2019" -A $arch -DONNX_USE_PROTOBUF_SHARED_LIBS=OFF -DProtobuf_USE_STATIC_LIBS=ON -DONNX_USE_LITE_PROTO=ON -DONNX_WERROR=ON -DONNX_DISABLE_EXCEPTIONS=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Release -DONNX_USE_MSVC_STATIC_RUNTIME=ON -DONNX_ML=1 -DONNX_BUILD_TESTS=ON -S . -B .setuptools-cmake-build\
79+
cmake -G "Visual Studio 16 2019" -A $arch -DONNX_USE_PROTOBUF_SHARED_LIBS=OFF -DONNX_USE_LITE_PROTO=ON -DONNX_WERROR=ON -DONNX_DISABLE_EXCEPTIONS=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Release -DONNX_USE_MSVC_STATIC_RUNTIME=ON -DONNX_ML=1 -DONNX_BUILD_TESTS=ON -S . -B .setuptools-cmake-build\
8080
cd .setuptools-cmake-build\
8181
msbuild onnx.sln /m /p:Configuration=Release
8282
@@ -89,7 +89,7 @@ jobs:
8989
cd ..
9090
git clean -xdf
9191
echo "Build ONNX with non-static registration for testing selective ONNX schema loading"
92-
cmake -G "Visual Studio 16 2019" -A $arch -DONNX_USE_PROTOBUF_SHARED_LIBS=OFF -DProtobuf_USE_STATIC_LIBS=ON -DONNX_USE_LITE_PROTO=ON -DONNX_WERROR=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Release -DONNX_USE_MSVC_STATIC_RUNTIME=ON -DONNX_ML=1 -DONNX_BUILD_TESTS=ON -DONNX_DISABLE_STATIC_REGISTRATION=ON -S . -B .setuptools-cmake-build\
92+
cmake -G "Visual Studio 16 2019" -A $arch -DONNX_USE_PROTOBUF_SHARED_LIBS=OFF -DONNX_USE_LITE_PROTO=ON -DONNX_WERROR=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Release -DONNX_USE_MSVC_STATIC_RUNTIME=ON -DONNX_ML=1 -DONNX_BUILD_TESTS=ON -DONNX_DISABLE_STATIC_REGISTRATION=ON -S . -B .setuptools-cmake-build\
9393
cd .setuptools-cmake-build\
9494
msbuild onnx.sln /m /p:Configuration=Release
9595

CMakeLists.txt

+5-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ cmake_policy(SET CMP0063 NEW)
1616
# Project
1717
project(onnx C CXX)
1818
option(ONNX_BUILD_BENCHMARKS "Build ONNX micro-benchmarks" OFF)
19-
option(ONNX_USE_PROTOBUF_SHARED_LIBS "Build ONNX using protobuf shared library. Sets PROTOBUF_USE_DLLS CMAKE Flag " OFF)
19+
option(ONNX_USE_PROTOBUF_SHARED_LIBS "Build ONNX using protobuf shared library. Sets PROTOBUF_USE_DLLS CMAKE Flag and Protobuf_USE_STATIC_LIBS. " OFF)
2020

2121
option(BUILD_ONNX_PYTHON "Build Python binaries" OFF)
2222
option(ONNX_GEN_PB_TYPE_STUBS "Generate protobuf python type stubs" ON)
@@ -48,11 +48,14 @@ if(NOT DEFINED ONNX_VERIFY_PROTO3)
4848
option(ONNX_VERIFY_PROTO3 "Generate code by proto3" ${PROTO3_ENABLED})
4949
endif()
5050

51-
if (ONNX_USE_PROTOBUF_SHARED_LIBS)
51+
if(ONNX_USE_PROTOBUF_SHARED_LIBS)
5252
if(MSVC)
5353
#TODO: if ONNX_USE_MSVC_STATIC_RUNTIME is ON, it may not work
5454
add_definitions(-DPROTOBUF_USE_DLLS)
5555
endif()
56+
set(Protobuf_USE_STATIC_LIBS OFF)
57+
else()
58+
set(Protobuf_USE_STATIC_LIBS ON)
5659
endif()
5760

5861
# Set C++11 as standard for the whole project

README.md

+64-85
Original file line numberDiff line numberDiff line change
@@ -50,116 +50,83 @@ Stay up to date with the latest ONNX news. [[Facebook](https://www.facebook.com/
5050

5151
# Installation
5252

53-
## Binaries
54-
55-
A binary build of ONNX is available from [Conda](https://conda.io), in [conda-forge](https://conda-forge.org/):
56-
53+
## Official Python packages
54+
ONNX released packages are published in PyPi.
5755
```
58-
conda install -c conda-forge onnx
56+
pip install numpy protobuf==3.11.3
57+
pip install onnx
5958
```
6059

61-
## Source
62-
63-
If you have installed onnx on your machine, please `pip uninstall onnx` first before the following process of build from source.
60+
[Weekly packages](https://test.pypi.org/project/onnx-weekly/) are published in test pypi to enable experimentation and early testing.
6461

65-
### Linux and MacOS
66-
You will need an install of Protobuf and NumPy to build ONNX. One easy
67-
way to get these dependencies is via
68-
[Anaconda](https://www.anaconda.com/download/):
6962

63+
## Conda packages
64+
A binary build of ONNX is available from [Conda](https://conda.io), in [conda-forge](https://conda-forge.org/):
7065
```
71-
# Use conda-forge protobuf, as default doesn't come with protoc
72-
conda install -c conda-forge protobuf numpy
66+
conda install -c conda-forge numpy protobuf==3.11.3 libprotobuf=3.11.3
67+
conda install -c conda-forge onnx
7368
```
7469

75-
You can then install ONNX from PyPi (Note: Set environment variable `ONNX_ML=1` for onnx-ml):
70+
You can also use the [onnx-dev docker image](https://hub.docker.com/r/onnx/onnx-dev) for a Linux-based installation without having to worry about dependency versioning.
7671

77-
```
78-
pip install onnx
79-
```
8072

81-
Alternatively, you can also build and install ONNX locally from source code:
73+
## Build ONNX from Source
74+
Before building from source uninstall any existing versions of onnx `pip uninstall onnx`.
75+
If you are building ONNX from source, it is recommended that you also build Protobuf locally as a static library. Specifically on Windows, the version distributed with conda-forge is a DLL, but ONNX expects it to be a static library. Building protobuf locally also let's you control the verison of protobuf. The tested and recommended version is 3.11.3.
8276

77+
Note for Windows : The instructions in this README assume you are using Visual Studio. It is recommended that you run all the commands from a shell started from "Developer Command Prompt for VS 2019" and keep the build system generator for cmake (e.g., cmake -G "Visual Studio 16 2019") consistent while building protobuf as well as ONNX.
8378
```
8479
git clone https://github.com/onnx/onnx.git
8580
cd onnx
8681
git submodule update --init --recursive
87-
python setup.py install
88-
```
89-
90-
Note: When installing in a non-Anaconda environment, make sure to install the Protobuf compiler before running the pip installation of onnx. For example, on Ubuntu:
91-
92-
```
93-
sudo apt-get install protobuf-compiler libprotoc-dev
94-
pip install onnx
82+
# prefer lite proto
83+
set CMAKE_ARGS=-DONNX_USE_LITE_PROTO=ON
84+
pip install -e .
9585
```
9686

97-
### Windows
98-
If you are building ONNX from source on Windows, it is recommended that you also build Protobuf locally as a static library. The version distributed with conda-forge is a DLL, but ONNX expects it to be a static library.
99-
100-
Note that the instructions in this README assume you are using Visual Studio. It is recommended that you run all the commands from a shell started from "Developer Command Prompt for VS 2019" and keep the build system generator for cmake (e.g., cmake -G "Visual Studio 16 2019") consistent.
101-
102-
#### Build Protobuf and ONNX on Windows
103-
Step 1: Build Protobuf locally
87+
### Building Protobuf from source
88+
* **Windows**
10489
```
10590
git clone https://github.com/protocolbuffers/protobuf.git
10691
cd protobuf
10792
git checkout v3.11.3
10893
cd cmake
109-
# Explicitly set -Dprotobuf_MSVC_STATIC_RUNTIME=OFF to make sure protobuf does not statically link to runtime library
110-
cmake -G -A -Dprotobuf_MSVC_STATIC_RUNTIME=OFF -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_EXAMPLES=OFF -DCMAKE_INSTALL_PREFIX=<protobuf_install_dir>
111-
# For example:
112-
# cmake -G "Visual Studio 16 2019" -A x64 -Dprotobuf_MSVC_STATIC_RUNTIME=OFF -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_EXAMPLES=OFF -DCMAKE_INSTALL_PREFIX=..\install
94+
cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_INSTALL_PREFIX=<protobug_install_dir> -Dprotobuf_MSVC_STATIC_RUNTIME=ON -Dprotobuf_BUILD_SHARED_LIBS=OFF -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_EXAMPLES=OFF .
11395
msbuild protobuf.sln /m /p:Configuration=Release
11496
msbuild INSTALL.vcxproj /p:Configuration=Release
11597
```
11698

117-
Step 2: Build ONNX
99+
* **Linux**
118100
```
119-
# Get ONNX
120-
git clone https://github.com/onnx/onnx.git
121-
cd onnx
101+
git clone https://github.com/protocolbuffers/protobuf.git
102+
cd protobuf
103+
git checkout v3.11.3
122104
git submodule update --init --recursive
123-
124-
# Set environment variables to find protobuf and turn off static linking of ONNX to runtime library.
125-
# Even better option is to add it to user\system PATH so this step can be performed only once.
126-
# For more details check https://docs.microsoft.com/en-us/cpp/build/reference/md-mt-ld-use-run-time-library?view=vs-2017
127-
set PATH=<protobuf_install_dir>\bin;<protobuf_install_dir>\include;<protobuf_install_dir>\libs;%PATH%
128-
set USE_MSVC_STATIC_RUNTIME=0
129-
130-
# use the static installed protobuf
131-
set CMAKE_ARGS=-DONNX_USE_PROTOBUF_SHARED_LIBS=OFF -DProtobuf_USE_STATIC_LIBS=ON
132-
133-
# Optional: Set environment variable `ONNX_ML=1` for onnx-ml
134-
135-
# Build ONNX
136-
python setup.py install
105+
mkdir build_source && cd build_source
106+
cmake ../cmake -Dprotobuf_BUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_SYSCONFDIR=/etc -DCMAKE_POSITION_INDEPENDENT_CODE=ON -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release
107+
make -j$(nproc)
108+
make install
137109
```
138110

139-
If you would prefer to use Protobuf from conda-forge instead of building Protobuf from source, you can use the following instructions.
140-
141-
#### Build ONNX on Windows with Anaconda
142-
111+
* **Mac**
112+
```
113+
export NUM_CORES=`sysctl -n hw.ncpu`
114+
brew update
115+
brew install autoconf && brew install automake
116+
wget https://github.com/protocolbuffers/protobuf/releases/download/v3.11.3/protobuf-cpp-3.11.3.tar.gz
117+
tar -xvf protobuf-cpp-3.11.3.tar.gz
118+
cd protobuf-3.11.3
119+
mkdir build_source && cd build_source
120+
cmake ../cmake -Dprotobuf_BUILD_SHARED_LIBS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release
121+
make -j${NUM_CORES}
122+
make install
143123
```
144-
# Use conda-forge protobuf
145-
conda install -c conda-forge numpy libprotobuf=3.11.3 protobuf
146-
147-
# Get ONNX
148-
git clone https://github.com/onnx/onnx.git
149-
cd onnx
150-
git submodule update --init --recursive
151-
152-
# Set environment variable for ONNX to use protobuf shared lib
153-
set USE_MSVC_STATIC_RUNTIME=0
154-
set CMAKE_ARGS=-DONNX_USE_PROTOBUF_SHARED_LIBS=ON -DProtobuf_USE_STATIC_LIBS=OFF -DONNX_USE_LITE_PROTO=ON
155124

156-
# Build ONNX
157-
# Optional: Set environment variable `ONNX_ML=1` for onnx-ml
125+
Once build is successful, update PATH to include protobuf paths. Example on Windows:
126+
set PATH=<protobuf_install_dir>\bin;<protobuf_install_dir>\include;<protobuf_install_dir>\libs;%PATH%
158127

159-
python setup.py install
160-
```
161128

162-
#### Build ONNX on ARM 64
129+
### Build ONNX on ARM 64
163130
If you are building ONNX on an ARM 64 device, please make sure to install the dependencies appropriately.
164131

165132
```
@@ -178,21 +145,33 @@ python -c "import onnx"
178145
to verify it works.
179146

180147

181-
#### Common Errors
182-
**Environment variables**: `USE_MSVC_STATIC_RUNTIME` (should be 1 or 0, not ON or OFF)
148+
## Common Build Options
149+
For full list refer to CMakeLists.txt
150+
**Environment variables**
151+
* `USE_MSVC_STATIC_RUNTIME` should be 1 or 0, not ON or OFF. When set to 1 onnx links statically to runtime library.
152+
**Default**: USE_MSVC_STATIC_RUNTIME=1
183153

184-
**CMake variables**: `ONNX_USE_PROTOBUF_SHARED_LIBS`, `Protobuf_USE_STATIC_LIBS`
154+
* `DEBUG` should be 0 or 1. When set to 1 onnx is built in debug mode. or debug versions of the dependencies, you need to open the [CMakeLists file][CMakeLists] and append a letter `d` at the end of the package name lines. For example, `NAMES protobuf-lite` would become `NAMES protobuf-lited`.
155+
**Default**: Debug=0
185156

186-
If `ONNX_USE_PROTOBUF_SHARED_LIBS` is ON then `Protobuf_USE_STATIC_LIBS` must be OFF and `USE_MSVC_STATIC_RUNTIME` must be 0.
187-
If `ONNX_USE_PROTOBUF_SHARED_LIBS` is OFF then `Protobuf_USE_STATIC_LIBS` must be ON and `USE_MSVC_STATIC_RUNTIME` can be 1 or 0.
157+
**CMake variables**
158+
* `ONNX_USE_PROTOBUF_SHARED_LIBS` should be ON or OFF.
159+
**Default**: ONNX_USE_PROTOBUF_SHARED_LIBS=OFF USE_MSVC_STATIC_RUNTIME=1
160+
`ONNX_USE_PROTOBUF_SHARED_LIBS` determines how onnx links to protobuf libraries.
161+
- When set to ON - onnx will dynamically link to protobuf shared libs, PROTOBUF_USE_DLLS will be defined as described [here](https://github.com/protocolbuffers/protobuf/blob/master/cmake/README.md#dlls-vs-static-linking), Protobuf_USE_STATIC_LIBS will be set to OFF and `USE_MSVC_STATIC_RUNTIME` must be 0.
162+
- When set to OFF - onnx will link statically to protobuf, and Protobuf_USE_STATIC_LIBS will be set to ON (to force the use of the static libraries) and `USE_MSVC_STATIC_RUNTIME` can be 0 or 1.
188163

189-
Note that the `import onnx` command does not work from the source checkout directory; in this case you'll see `ModuleNotFoundError: No module named 'onnx.onnx_cpp2py_export'`. Change into another directory to fix this error.
164+
* `ONNX_USE_LITE_PROTO` should be ON or OFF. When set to ON onnx uses lite protobuf instead of full protobuf.
165+
**Default**: ONNX_USE_LITE_PROTO=OFF
190166

191-
Building ONNX on Ubuntu works well, but on CentOS/RHEL and other ManyLinux systems, you might need to open the [CMakeLists file][CMakeLists] and replace all instances of `/lib` with `/lib64`.
167+
* `ONNX_WERROR` should be ON or OFF. When set to ON warnings are treated as errors.
168+
**Default**: ONNX_WERROR=OFF in local builds, ON in CI and release pipelines.
192169

193-
If you want to build ONNX on Debug mode, remember to set the environment variable `DEBUG=1`. For debug versions of the dependencies, you need to open the [CMakeLists file][CMakeLists] and append a letter `d` at the end of the package name lines. For example, `NAMES protobuf-lite` would become `NAMES protobuf-lited`.
194170

195-
You can also use the [onnx-dev docker image](https://hub.docker.com/r/onnx/onnx-dev) for a Linux-based installation without having to worry about dependency versioning.
171+
## Common Errors
172+
* Note: the `import onnx` command does not work from the source checkout directory; in this case you'll see `ModuleNotFoundError: No module named 'onnx.onnx_cpp2py_export'`. Change into another directory to fix this error.
173+
174+
* Building ONNX on Ubuntu works well, but on CentOS/RHEL and other ManyLinux systems, you might need to open the [CMakeLists file][CMakeLists] and replace all instances of `/lib` with `/lib64`.
196175

197176
# Testing
198177

cmake/summary.cmake

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ function (onnx_print_configuration_summary)
2121
message(STATUS " ONNX NAMESPACE : ${ONNX_NAMESPACE}")
2222
message(STATUS " ONNX_USE_LITE_PROTO : ${ONNX_USE_LITE_PROTO}")
2323
message(STATUS " USE_PROTOBUF_SHARED_LIBS : ${ONNX_USE_PROTOBUF_SHARED_LIBS}")
24+
message(STATUS " Protobuf_USE_STATIC_LIBS : ${Protobuf_USE_STATIC_LIBS}")
2425
message(STATUS " ONNX_DISABLE_EXCEPTIONS : ${ONNX_DISABLE_EXCEPTIONS}")
2526
message(STATUS " ONNX_WERROR : ${ONNX_WERROR}")
2627
message(STATUS " ONNX_BUILD_TESTS : ${ONNX_BUILD_TESTS}")

0 commit comments

Comments
 (0)