question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SyntaxError: invalid syntax

See original GitHub issue

Description

Not being able to make

Error message

-- ******** Summary ********
--   CMake version             : 3.22.1
--   CMake command             : /home/XXX/cmake-3.22.1/bin/cmake
--   System                    : Linux
--   C++ compiler              : /usr/bin/c++
--   C++ compiler version      : 7.5.0
--   CXX flags                 :  -Wall -Wno-deprecated-declarations -Wno-unused-function -Wnon-virtual-dtor
--   Build type                : Release
--   Compile definitions       : SOURCE_LENGTH=39;ONNX_NAMESPACE=onnx2trt_onnx;__STDC_FORMAT_MACROS
--   CMAKE_PREFIX_PATH         : 
--   CMAKE_INSTALL_PREFIX      : /usr/local
--   CMAKE_MODULE_PATH         : 
-- 
--   ONNX version              : 1.12.0
--   ONNX NAMESPACE            : onnx2trt_onnx
--   ONNX_USE_LITE_PROTO       : OFF
--   USE_PROTOBUF_SHARED_LIBS  : OFF
--   Protobuf_USE_STATIC_LIBS  : ON
--   ONNX_DISABLE_EXCEPTIONS   : OFF
--   ONNX_WERROR               : OFF
--   ONNX_BUILD_TESTS          : OFF
--   ONNX_BUILD_BENCHMARKS     : OFF
--   ONNXIFI_DUMMY_BACKEND     : OFF
--   ONNXIFI_ENABLE_EXT        : OFF
-- 
--   Protobuf compiler         : /usr/local/bin/protoc
--   Protobuf includes         : /usr/local/include
--   Protobuf libraries        : /usr/local/lib/libprotobuf.so;-lpthread
--   BUILD_ONNX_PYTHON         : OFF
-- Found CUDA headers at /usr/local/cuda-11.4/include
-- Found TensorRT headers at /home/XXX/opt/TensorRT-8.4.1.5/include
-- Find TensorRT libs at /home/XXX/opt/TensorRT-8.4.1.5/lib/libnvinfer.so;/home/XXX/opt/TensorRT-8.4.1.5/lib/libnvinfer_plugin.so
-- Configuring done
-- Generating done
-- Build files have been written to: /home/XXX/Desktop/onnx-tensorrt/build
  File "/home/XXX/Desktop/onnx-tensorrt/third_party/onnx/onnx/gen_proto.py", line 35
    def process_ifs(lines: Iterable[str], onnx_ml: bool) -> Iterable[str]:
                         ^
SyntaxError: invalid syntax
third_party/onnx/CMakeFiles/gen_onnx_proto.dir/build.make:80: recipe for target 'third_party/onnx/onnx/onnx_onnx2trt_onnx-ml.proto' failed
make[2]: *** [third_party/onnx/onnx/onnx_onnx2trt_onnx-ml.proto] Error 1
CMakeFiles/Makefile2:163: recipe for target 'third_party/onnx/CMakeFiles/gen_onnx_proto.dir/all' failed
make[1]: *** [third_party/onnx/CMakeFiles/gen_onnx_proto.dir/all] Error 2
Makefile:155: recipe for target 'all' failed
make: *** [all] Error 2

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
romain87400commented, Sep 21, 2022

Yes, now i understand my problem, when the cmake load python, she take python 2.7 and not python 3.6.9 😦 – Found PythonInterp: /usr/bin/python (found version “2.7.17”) – Found PythonLibs: /usr/lib/aarch64-linux-gnu/libpython2.7.so (found version “2.7.17”) i changed CMakelist.txt, of Onnx , find_package(PythonInterp ${PY_VERSION} REQUIRED) - > find_package(PythonInterp 3.6.9 REQUIRED) find_package(PythonLibs ${PY_VERSION}) -> find_package(PythonLibs 3.6.9)

Now Onnx compiles fine, but with onnx-tensorrt I have an error, I think I have to change something because when I compile I have this and other errors identical: [ 47%] Building CXX object CMakeFiles/nvonnxparser.dir/builtin_op_importers.cpp.o In file included from /home/databird/Developpement/library/test/onnx-tensorrt/ImporterContext.hpp:8:0, from /home/databird/Developpement/library/test/onnx-tensorrt/ModelImporter.hpp:7, from /home/databird/Developpement/library/test/onnx-tensorrt/NvOnnxParser.cpp:6: /home/databird/Developpement/library/test/onnx-tensorrt/onnx2trt_utils.hpp: In function ‘nvinfer1::IConstantLayer* onnx2trt::addConstantScalar(onnx2trt::IImporterContext*, ScalarType, onnx2trt::ShapedWeights::DataType, nvinfer1::Dims)’: /home/databird/Developpement/library/test/onnx-tensorrt/onnx2trt_utils.hpp:105:21: error: ‘class nvinfer1::INetworkDefinition’ has no member named ‘setWeightsName’; did you mean ‘setName’? ctx->network()->setWeightsName(scalarWeights, scalarWeights.getName());

Maybe my tensorrt version (7.1.3.0). I cloned this depot https://github.com/onnx/onnx-tensorrt/tree/7.1 But it’s a other subject i think we can close this topic. Thanks for your help and your patience. Have a nice day and continue your wonderful work ! 😃

0reactions
yinguobingcommented, Sep 28, 2022

Encountered same issue while trying to build TensorRT-OSS. This issue could be resolved by a simple modification of the CMakeList.txt located here:

${TensorRT-OSS}//parsers/onnx/third_party/onnx/CMakeLists.txt

Note line 114, there is a comment like this:

# find_package Python has replaced PythonInterp and PythonLibs since cmake 3.12
# Use the following command in the future; now this is only compatible with the latest pybind11

Do what the comment said, uncomment line 116 and comment line 117 & 118:

# find_package Python has replaced PythonInterp and PythonLibs since cmake 3.12
# Use the following command in the future; now this is only compatible with the latest pybind11
find_package(Python ${PY_VERSION} COMPONENTS Interpreter Development REQUIRED)
# find_package(PythonInterp ${PY_VERSION} REQUIRED)
# find_package(PythonLibs ${PY_VERSION})

Then python3 will be picked rather than python2.

The TensorRT-OSS commit hash: a912a045c32a2247b0d1d669962706d28cac7e40

Read more comments on GitHub >

github_iconTop Results From Across the Web

Invalid Syntax in Python: Common Reasons for SyntaxError
The interpreter will find any invalid syntax in Python during this first stage of program execution, also known as the parsing stage. If...
Read more >
How to Fix Invalid SyntaxError in Python
The Python SyntaxError occurs when the interpreter encounters invalid syntax in code. When Python code is executed, the interpreter parses ...
Read more >
python - Why do I get the syntax error "SyntaxError: invalid ...
When an error is reported on a line that appears correct, try removing (or commenting out) the line where the error appears to...
Read more >
SyntaxError: invalid syntax
Python's "invalid syntax" error message comes up often, especially when you're first learning Python. What usually causes this error and how can you...
Read more >
SyntaxError in Python: How to Handle Invalid Syntax in Python
In this tutorial, I will teach you how to handle SyntaxError in Python, including numerous strategies for handling invalid syntax in Python.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found