Error: static assertion failed: We only support non-string scalars in RepeatedField

Trying to build PyTorch commit aaa989c24451259aff4f0b70070bd7ab8380944d , from source under

➜  ~ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 22.04.3 LTS
Release:	22.04
Codename:	jammy
➜  ~ uname -r
5.19.0-50-generic
➜  ~ python --version
Python 3.10.12
➜  ~ gcc --version
gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

And, I got the following ERROR messages:

/usr/local/include/google/protobuf/repeated_field.h: In instantiation of ‘static constexpr void google::protobuf::RepeatedField< <template-parameter-1-1> >::StaticValidityCheck() [with Element = signed char]’:
/usr/local/include/google/protobuf/repeated_field.h:526:22:   required from ‘void caffe2::onnx::ConvertIntegralValueToCaffe2(caffe2::OperatorDef*, caffe2::Argument*, const onnx_torch::TensorProto&) [with T = signed char]’
....../pytorch/caffe2/onnx/backend.cc:1799:61:   required from here
....../pytorch/caffe2/onnx/backend.cc:1710:40:   in ‘constexpr’ expansion of ‘tmp.google::protobuf::RepeatedField<signed char>::RepeatedField()’
/usr/local/include/google/protobuf/repeated_field.h:187:52: error: static assertion failed: We only support non-string scalars in RepeatedField.
  187 |                           is_proto_enum<Element>>::value,
      |                                                    ^~~~~
/usr/local/include/google/protobuf/repeated_field.h:187:52: note: ‘std::integral_constant<bool, false>::value’ evaluates to false
/usr/local/include/google/protobuf/repeated_field.h: In instantiation of ‘static constexpr void google::protobuf::RepeatedField< <template-parameter-1-1> >::StaticValidityCheck() [with Element = unsigned char]’:
/usr/local/include/google/protobuf/repeated_field.h:526:22:   required from ‘void caffe2::onnx::ConvertIntegralValueToCaffe2(caffe2::OperatorDef*, caffe2::Argument*, const onnx_torch::TensorProto&) [with T = unsigned char]’
....../pytorch/caffe2/onnx/backend.cc:1802:62:   required from here
....../pytorch/caffe2/onnx/backend.cc:1710:40:   in ‘constexpr’ expansion of ‘tmp.google::protobuf::RepeatedField<unsigned char>::RepeatedField()’
/usr/local/include/google/protobuf/repeated_field.h:187:52: error: static assertion failed: We only support non-string scalars in RepeatedField.
/usr/local/include/google/protobuf/repeated_field.h:187:52: note: ‘std::integral_constant<bool, false>::value’ evaluates to false
/usr/local/include/google/protobuf/repeated_field.h: In instantiation of ‘static constexpr void google::protobuf::RepeatedField< <template-parameter-1-1> >::StaticValidityCheck() [with Element = short unsigned int]’:
/usr/local/include/google/protobuf/repeated_field.h:526:22:   required from ‘void caffe2::onnx::ConvertIntegralValueToCaffe2(caffe2::OperatorDef*, caffe2::Argument*, const onnx_torch::TensorProto&) [with T = short unsigned int]’
....../pytorch/caffe2/onnx/backend.cc:1808:63:   required from here
....../pytorch/caffe2/onnx/backend.cc:1710:40:   in ‘constexpr’ expansion of ‘tmp.google::protobuf::RepeatedField<short unsigned int>::RepeatedField()’
/usr/local/include/google/protobuf/repeated_field.h:187:52: error: static assertion failed: We only support non-string scalars in RepeatedField.
/usr/local/include/google/protobuf/repeated_field.h:187:52: note: ‘std::integral_constant<bool, false>::value’ evaluates to false
/usr/local/include/google/protobuf/repeated_field.h: In instantiation of ‘static constexpr void google::protobuf::RepeatedField< <template-parameter-1-1> >::StaticValidityCheck() [with Element = short int]’:
/usr/local/include/google/protobuf/repeated_field.h:526:22:   required from ‘void caffe2::onnx::ConvertIntegralValueToCaffe2(caffe2::OperatorDef*, caffe2::Argument*, const onnx_torch::TensorProto&) [with T = short int]’
....../pytorch/caffe2/onnx/backend.cc:1811:62:   required from here
....../pytorch/caffe2/onnx/backend.cc:1710:40:   in ‘constexpr’ expansion of ‘tmp.google::protobuf::RepeatedField<short int>::RepeatedField()’
/usr/local/include/google/protobuf/repeated_field.h:187:52: error: static assertion failed: We only support non-string scalars in RepeatedField.
/usr/local/include/google/protobuf/repeated_field.h:187:52: note: ‘std::integral_constant<bool, false>::value’ evaluates to false
cc1plus: note: unrecognized command-line option ‘-Wno-aligned-allocation-unavailable’ may have been intended to silence earlier diagnostics
cc1plus: note: unrecognized command-line option ‘-Wno-unused-private-field’ may have been intended to silence earlier diagnostics
cc1plus: note: unrecognized command-line option ‘-Wno-invalid-partial-specialization’ may have been intended to silence earlier diagnostics

Hi, May I ask you how to solve this problem later, I encountered the same problem

Hi

same here when try to build pytorch 2.1.0 with protobuf 24.3

greetings