‘qnnp_setup_add_nc_q8’ was not declared in this scope

I have the following pytorch installation error. Could anyone help ?

‘qnnp_setup_add_nc_q8’ was not declared in this scope

[ 49%] Building CXX object caffe2/CMakeFiles/caffe2.dir/operators/rnn/recurrent_network_blob_fetcher_op.cc.o
[ 49%] Building CXX object caffe2/CMakeFiles/caffe2.dir/operators/rnn/recurrent_network_executor.cc.o
[ 49%] Building CXX object caffe2/CMakeFiles/caffe2.dir/operators/rnn/recurrent_network_op.cc.o
[ 49%] Building CXX object caffe2/CMakeFiles/caffe2.dir/operators/quantized/init_qnnpack.cc.o
[ 50%] Building CXX object caffe2/CMakeFiles/caffe2.dir/operators/quantized/int8_add_op.cc.o
[ 50%] Building CXX object caffe2/CMakeFiles/caffe2.dir/operators/quantized/int8_average_pool_op.cc.o
[ 50%] Building CXX object caffe2/CMakeFiles/caffe2.dir/operators/quantized/int8_channel_shuffle_op.cc.o
[ 50%] Building CXX object caffe2/CMakeFiles/caffe2.dir/operators/quantized/int8_concat_op.cc.o
[ 50%] Building CXX object caffe2/CMakeFiles/caffe2.dir/operators/quantized/int8_conv_op.cc.o
[ 50%] Building CXX object caffe2/CMakeFiles/caffe2.dir/operators/quantized/int8_conv_transpose_op.cc.o
In file included from /home/phung/Downloads/pytorch/caffe2/operators/quantized/int8_add_op.cc:3:0:
/home/phung/Downloads/pytorch/caffe2/operators/quantized/int8_add_op.h: In member function ‘bool caffe2::int8::Int8AddOp::RunOnDevice()’:
/home/phung/Downloads/pytorch/caffe2/operators/quantized/int8_add_op.h:59:40: error: there are no arguments to ‘qnnp_create_add_nc_q8’ that depend on a template parameter, so a declaration of ‘qnnp_create_add_nc_q8’ must be available [-fpermissive]
const qnnp_status createStatus = qnnp_create_add_nc_q8(
^~~~~~~~~~~~~~~~~~~~~
/home/phung/Downloads/pytorch/caffe2/operators/quantized/int8_add_op.h:59:40: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
/home/phung/Downloads/pytorch/caffe2/operators/quantized/int8_add_op.h:73:37: error: there are no arguments to ‘qnnp_setup_add_nc_q8’ that depend on a template parameter, so a declaration of ‘qnnp_setup_add_nc_q8’ must be available [-fpermissive]
const qnnp_status setupStatus = qnnp_setup_add_nc_q8(
^~~~~~~~~~~~~~~~~~~~
[ 50%] Building CXX object caffe2/CMakeFiles/caffe2.dir/operators/quantized/int8_dequantize_op.cc.o
/home/phung/Downloads/pytorch/caffe2/operators/quantized/int8_add_op.h: In instantiation of ‘bool caffe2::int8::Int8AddOp::RunOnDevice() [with caffe2::int8::Activation Ac = (caffe2::int8::Activation)1]’:
/home/phung/Downloads/pytorch/caffe2/operators/quantized/int8_add_op.cc:68:1: required from here
/home/phung/Downloads/pytorch/caffe2/operators/quantized/int8_add_op.h:59:61: error: ‘qnnp_create_add_nc_q8’ was not declared in this scope
const qnnp_status createStatus = qnnp_create_add_nc_q8(
~~~~~~~~~~~~~~~~~~~~~^
1 /* channels /,
~~~~~~~~~~~~~~~~~
A_zero_point, A_scale,
~~~~~~~~~~~~~~~~~~~~~~
B_zero_point, B_scale,
~~~~~~~~~~~~~~~~~~~~~~
static_cast<uint8_t>(Y_zero_point), Y_scale,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
activationLimits(Y_scale, Y_zero_point, Ac).first,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
activationLimits(Y_scale, Y_zero_point, Ac).second,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
&qnnpackOperator_);
~~~~~~~~~~~~~~~~~~
/home/phung/Downloads/pytorch/caffe2/operators/quantized/int8_add_op.h:73:57: error: ‘qnnp_setup_add_nc_q8’ was not declared in this scope
const qnnp_status setupStatus = qnnp_setup_add_nc_q8(
~~~~~~~~~~~~~~~~~~~~^
this->qnnpackOperator_,
~~~~~~~~~~~~~~~~~~~~~~~
A.t.numel() /
batch size /,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
A.t.template data<uint8_t>(),
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 /
A stride /,
~~~~~~~~~~~~~~~~~
B.t.template data<uint8_t>(),
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 /
B stride /,
~~~~~~~~~~~~~~~~~
Y->t.template mutable_data<uint8_t>(),
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 /
Y stride /);
~~~~~~~~~~~~~~~~~
[ 50%] Building CXX object caffe2/CMakeFiles/caffe2.dir/operators/quantized/int8_fc_op.cc.o
/home/phung/Downloads/pytorch/caffe2/operators/quantized/int8_add_op.h: In instantiation of ‘bool caffe2::int8::Int8AddOp::RunOnDevice() [with caffe2::int8::Activation Ac = (caffe2::int8::Activation)0]’:
/home/phung/Downloads/pytorch/caffe2/operators/quantized/int8_add_op.cc:68:1: required from here
/home/phung/Downloads/pytorch/caffe2/operators/quantized/int8_add_op.h:59:61: error: ‘qnnp_create_add_nc_q8’ was not declared in this scope
const qnnp_status createStatus = qnnp_create_add_nc_q8(
~~~~~~~~~~~~~~~~~~~~~^
1 /
channels /,
~~~~~~~~~~~~~~~~~
A_zero_point, A_scale,
~~~~~~~~~~~~~~~~~~~~~~
B_zero_point, B_scale,
~~~~~~~~~~~~~~~~~~~~~~
static_cast<uint8_t>(Y_zero_point), Y_scale,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
activationLimits(Y_scale, Y_zero_point, Ac).first,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
activationLimits(Y_scale, Y_zero_point, Ac).second,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
&qnnpackOperator_);
~~~~~~~~~~~~~~~~~~
/home/phung/Downloads/pytorch/caffe2/operators/quantized/int8_add_op.h:73:57: error: ‘qnnp_setup_add_nc_q8’ was not declared in this scope
const qnnp_status setupStatus = qnnp_setup_add_nc_q8(
~~~~~~~~~~~~~~~~~~~~^
this->qnnpackOperator_,
~~~~~~~~~~~~~~~~~~~~~~~
A.t.numel() /
batch size /,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
A.t.template data<uint8_t>(),
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 /
A stride /,
~~~~~~~~~~~~~~~~~
B.t.template data<uint8_t>(),
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 /
B stride /,
~~~~~~~~~~~~~~~~~
Y->t.template mutable_data<uint8_t>(),
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 /
Y stride */);
~~~~~~~~~~~~~~~~~
caffe2/CMakeFiles/caffe2.dir/build.make:12990: recipe for target ‘caffe2/CMakeFiles/caffe2.dir/operators/quantized/int8_add_op.cc.o’ failed
make[2]: *** [caffe2/CMakeFiles/caffe2.dir/operators/quantized/int8_add_op.cc.o] Error 1
make[2]: *** Waiting for unfinished jobs…
CMakeFiles/Makefile2:4589: recipe for target ‘caffe2/CMakeFiles/caffe2.dir/all’ failed
make[1]: *** [caffe2/CMakeFiles/caffe2.dir/all] Error 2
Makefile:140: recipe for target ‘all’ failed
make: *** [all] Error 2
Failed to run ‘bash …/tools/build_pytorch_libs.sh --use-cuda --use-nnpack --use-mkldnn --use-qnnpack caffe2’
phung@UbuntuHW15:~/Downloads/pytorch$

I encountered the same issue today and got around it by updating my qnnpack submodule.

cd third_party/QNNPACK
git pull origin master

As it worked with the current master branch I haven’t spent more time thinking about which version qnnpack should be updated to.

If this does not work, you may also consider disabling qnnpack build, there is a NO_QNNPACK option but I haven’t tried it.

1 Like

I have followed your suggestion regarding QNNPACK , but I faced some other error as follows:

Do you have any idea ?

[ 56%] Building CXX object caffe2/CMakeFiles/caffe2_pybind11_state.dir/python/pybind_state_dlpack.cc.o
[ 56%] Building NVCC (Device) object caffe2/CMakeFiles/caffe2_gpu.dir/__/aten/src/THC/caffe2_gpu_generated_THCTensorMath.cu.o
[ 56%] Building CXX object caffe2/torch/lib/THD/CMakeFiles/THD.dir/base/Cuda.cpp.o
[ 56%] Building NVCC (Device) object caffe2/CMakeFiles/caffe2_gpu.dir/__/aten/src/THC/caffe2_gpu_generated_THCTensorMathBlas.cu.o
/home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc: In lambda function:
/home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc:346:32: error: ‘const class pybind11::object’ has no member named ‘is’
             if (!device_option.is(py::none())) {
                                ^~
/home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc: In function ‘void caffe2::python::addObjectMethods(pybind11::module&)’:
/home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc:682:8: error: no matching function for call to ‘init(caffe2::python::addObjectMethods(pybind11::module&)::<lambda(const std::vector<pybind11::bytes>&, const std::vector<pybind11::bytes>&, const std::vector<std::__cxx11::basic_string<char> >&)>)’
       }));
        ^
In file included from /home/phung/Downloads/pytorch/caffe2/python/pybind_state_dlpack.h:9:0,
                 from /home/phung/Downloads/pytorch/caffe2/python/pybind_state.h:16,
                 from /home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc:1:
/usr/include/pybind11/pybind11.h:1418:51: note: candidate: template<class ... Args> pybind11::detail::init<Args ...> pybind11::init()
 template <typename... Args> detail::init<Args...> init() { return detail::init<Args...>(); }
                                                   ^~~~
/usr/include/pybind11/pybind11.h:1418:51: note:   template argument deduction/substitution failed:
/home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc:682:8: note:   candidate expects 0 arguments, 1 provided
       }));
        ^
/home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc: In lambda function:
/home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc:689:22: error: ‘const class pybind11::object’ has no member named ‘is’
             if (args.is(py::none())) {
                      ^~
/home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc: In function ‘void caffe2::python::addObjectMethods(pybind11::module&)’:
/home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc:884:12: error: no matching function for call to ‘init(caffe2::python::addObjectMethods(pybind11::module&)::<lambda(pybind11::bytes, pybind11::bytes)>)’
           }))
            ^
In file included from /home/phung/Downloads/pytorch/caffe2/python/pybind_state_dlpack.h:9:0,
                 from /home/phung/Downloads/pytorch/caffe2/python/pybind_state.h:16,
                 from /home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc:1:
/usr/include/pybind11/pybind11.h:1418:51: note: candidate: template<class ... Args> pybind11::detail::init<Args ...> pybind11::init()
 template <typename... Args> detail::init<Args...> init() { return detail::init<Args...>(); }
                                                   ^~~~
/usr/include/pybind11/pybind11.h:1418:51: note:   template argument deduction/substitution failed:
/home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc:884:12: note:   candidate expects 0 arguments, 1 provided
           }))
            ^
[ 56%] Building CXX object modules/observers/CMakeFiles/caffe2_observers.dir/observer_config.cc.o
/home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc: In lambda function:
/home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc:1053:31: error: ‘const class pybind11::object’ has no member named ‘is’
         if (create_if_missing.is(py::none())) {
                               ^~
/home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc: In lambda function:
/home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc:1065:25: error: ‘const class pybind11::object’ has no member named ‘is’
         if (root_folder.is(py::none())) {
                         ^~
[ 56%] Linking CXX shared library ../../lib/libcaffe2_module_test_dynamic.so
/home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc: In lambda function:
/home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc:1438:28: error: ‘class pybind11::object’ has no member named ‘is’
         if (!device_option.is(py::none())) {
                            ^~
In file included from /home/phung/Downloads/pytorch/caffe2/core/logging.h:2:0,
                 from /home/phung/Downloads/pytorch/caffe2/core/allocator.h:8,
                 from /home/phung/Downloads/pytorch/caffe2/core/context.h:9,
                 from /home/phung/Downloads/pytorch/caffe2/python/pybind_state.h:5,
                 from /home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc:1:
/home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc: In lambda function:
/home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc:1492:29: error: ‘class pybind11::object’ has no member named ‘is’
         CAFFE_ENFORCE(!func.is(py::none()));
                             ^
/home/phung/Downloads/pytorch/c10/util/Logging.h:82:11: note: in definition of macro ‘CAFFE_ENFORCE’
     if (!(condition)) {                                             \
           ^~~~~~~~~
/home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc: In lambda function:
/home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc:1508:29: error: ‘class pybind11::object’ has no member named ‘is’
         CAFFE_ENFORCE(!func.is(py::none()));
                             ^
/home/phung/Downloads/pytorch/c10/util/Logging.h:82:11: note: in definition of macro ‘CAFFE_ENFORCE’
     if (!(condition)) {                                             \
           ^~~~~~~~~
[ 56%] Built target caffe2_module_test_dynamic
[ 56%] Building CXX object modules/observers/CMakeFiles/caffe2_observers.dir/perf_observer.cc.o
/home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc: At global scope:
/home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc:1769:16: error: expected constructor, destructor, or type conversion before ‘(’ token
 PYBIND11_MODULE(caffe2_pybind11_state, m) {
                ^
[ 56%] Building CXX object caffe2/CMakeFiles/caffe2_pybind11_state.dir/python/pybind_state_nomni.cc.o

I didn’t have this problem. pybind11 is also a submodule of pytorch so it may be worth trying to update it too ?
The following command will update all submodules

git submodule update --recursive

I have pulled the latest commit for pybind11 , but the problem still persists. Why ?