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

username: jiapei100
cooked: <p>Trying to build PyTorch commit aaa989c24451259aff4f0b70070bd7ab8380944d , from source under</p>
<pre data-code-wrap="console"><code class="lang-plaintext">➜  ~ 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.
</code></pre>
<p>And, I got the following <strong>ERROR</strong> messages:</p>
<pre data-code-wrap="console"><code class="lang-plaintext">/usr/local/include/google/protobuf/repeated_field.h: In instantiation of ‘static constexpr void google::protobuf::RepeatedField&lt; &lt;template-parameter-1-1&gt; &gt;::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&amp;) [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&lt;signed char&gt;::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&lt;Element&gt;&gt;::value,
      |                                                    ^~~~~
/usr/local/include/google/protobuf/repeated_field.h:187:52: note: ‘std::integral_constant&lt;bool, false&gt;::value’ evaluates to false
/usr/local/include/google/protobuf/repeated_field.h: In instantiation of ‘static constexpr void google::protobuf::RepeatedField&lt; &lt;template-parameter-1-1&gt; &gt;::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&amp;) [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&lt;unsigned char&gt;::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&lt;bool, false&gt;::value’ evaluates to false
/usr/local/include/google/protobuf/repeated_field.h: In instantiation of ‘static constexpr void google::protobuf::RepeatedField&lt; &lt;template-parameter-1-1&gt; &gt;::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&amp;) [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&lt;short unsigned int&gt;::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&lt;bool, false&gt;::value’ evaluates to false
/usr/local/include/google/protobuf/repeated_field.h: In instantiation of ‘static constexpr void google::protobuf::RepeatedField&lt; &lt;template-parameter-1-1&gt; &gt;::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&amp;) [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&lt;short int&gt;::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&lt;bool, false&gt;::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
</code></pre>

username: hello-peter
cooked: <p>Hi, May I ask you how to solve this problem later, I encountered the same problem</p>

username: sl1pkn07
cooked: <p>Hi</p>
<p>same here when try to build pytorch 2.1.0 with protobuf 24.3</p>
<p>greetings</p>