Ncnn: trying to build with ncnn2int8 support but getting this error

Created on 22 Jan 2020  ·  13Comments  ·  Source: Tencent/ncnn

Scanning dependencies of target ncnn2int8
[ 70%] Building CXX object tools/quantize/CMakeFiles/ncnn2int8.dir/ncnn2int8.cpp.o
[ 70%] Built target ncnn2mem
Scanning dependencies of target ncnn2table
/home/orbosoham/ncnnnew/ncnn/tools/quantize/ncnn2int8.cpp: In function 'bool read_int8scale_table(const char*, std::map, std::vector >&, std::map, std::vector >&)':
/home/orbosoham/ncnnnew/ncnn/tools/quantize/ncnn2int8.cpp:98:17: error: 'nullptr' was not declared in this scope
char *pch = nullptr;

/home/orbosoham/ncnnnew/ncnn/tools/quantize/ncnn2int8.cpp: In member function 'int NetQuantize::quantize_convolution()':
/home/orbosoham/ncnnnew/ncnn/tools/quantize/ncnn2int8.cpp:182:14: error: 'iter_data' does not name a type
auto iter_data = blob_int8scale_table.find(layers[i]->name);
^
/home/orbosoham/ncnnnew/ncnn/tools/quantize/ncnn2int8.cpp:183:13: error: 'iter_data' was not declared in this scope
if (iter_data == blob_int8scale_table.end())
^
/home/orbosoham/ncnnnew/ncnn/tools/quantize/ncnn2int8.cpp:189:14: error: 'iter' does not name a type
auto iter = weight_int8scale_table.find(key);

/home/orbosoham/ncnnnew/ncnn/tools/quantize/ncnn2int8.cpp:190:13: error: 'iter' was not declared in this scope
if (iter == weight_int8scale_table.end())
^
/home/orbosoham/ncnnnew/ncnn/tools/quantize/ncnn2int8.cpp:197:14: error: 'convolution' does not name a type
auto convolution = (ncnn::Convolution*)layers[i];
^
/home/orbosoham/ncnnnew/ncnn/tools/quantize/ncnn2int8.cpp:199:54: error: 'iter' was not declared in this scope

Most helpful comment

solved:
by adding following to cmakelist
set (CMAKE_CXX_STANDARD 11)

This was the solution for the last issue that happened to me. It works in version 4.2.

Thanks.

All 13 comments

solved:
by adding following to cmakelist
set (CMAKE_CXX_STANDARD 11)

I went here to write the same issue. But there it is, same case. But there is another problem, related with Vulkan, right now it has a segmentation fault (for example when is running the mnet.25-opt for retinaface algorithm). Not sure if your solution can solve that too :c

This is not solved yet. I added the line in the CMakeList and nothing happened. Same error.

[ 96%] Linking CXX executable ncnn2int8
[ 96%] Built target ncnn2int8
Scanning dependencies of target test_softmax
/opt/ncnn/tools/quantize/ncnn2table.cpp:732:9: warning: braces around scalar initializer
[-Wbraced-scalar-init]
{
^
/opt/ncnn/tools/quantize/ncnn2table.cpp:746:16: error: 'has' is a protected member of
'cv::CommandLineParser'
if (parser.has("help"))
^
/usr/local/Cellar/opencv@2/2.4.13.7_5/include/opencv2/core/core.hpp:4818:10: note: declared
protected here
bool has(const std::string& keys);
^
/opt/ncnn/tools/quantize/ncnn2table.cpp:746:9: error: 'this' argument to member function 'has' has
type 'const cv::CommandLineParser', but function is not marked const
if (parser.has("help"))
^~
/usr/local/Cellar/opencv@2/2.4.13.7_5/include/opencv2/core/core.hpp:4818:10: note: 'has' declared
here
bool has(const std::string& keys);
^
/opt/ncnn/tools/quantize/ncnn2table.cpp:748:16: error: no member named 'printMessage' in
'cv::CommandLineParser'
parser.printMessage();
~~ ^
/opt/ncnn/tools/quantize/ncnn2table.cpp:753:17: error: 'has' is a protected member of
'cv::CommandLineParser'
if (!parser.has("param") || !parser.has("bin") || !parser.has("images") || !parser.has("...
^
/usr/local/Cellar/opencv@2/2.4.13.7_5/include/opencv2/core/core.hpp:4818:10: note: declared
protected here
bool has(const std::string& keys);
^
/opt/ncnn/tools/quantize/ncnn2table.cpp:753:10: error: 'this' argument to member function 'has' has
type 'const cv::CommandLineParser', but function is not marked const
if (!parser.has("param") || !parser.has("bin") || !parser.has("images") || !parser.has("...
^~
/usr/local/Cellar/opencv@2/2.4.13.7_5/include/opencv2/core/core.hpp:4818:10: note: 'has' declared
here
bool has(const std::string& keys);
^
/opt/ncnn/tools/quantize/ncnn2table.cpp:753:41: error: 'has' is a protected member of
'cv::CommandLineParser'
if (!parser.has("param") || !parser.has("bin") || !parser.has("images") || !parser.has("...
^
/usr/local/Cellar/opencv@2/2.4.13.7_5/include/opencv2/core/core.hpp:4818:10: note: declared
protected here
bool has(const std::string& keys);
^
/opt/ncnn/tools/quantize/ncnn2table.cpp:753:34: error: 'this' argument to member function 'has' has
type 'const cv::CommandLineParser', but function is not marked const
if (!parser.has("param") || !parser.has("bin") || !parser.has("images") || !parser.has("...
^~
/usr/local/Cellar/opencv@2/2.4.13.7_5/include/opencv2/core/core.hpp:4818:10: note: 'has' declared
here
bool has(const std::string& keys);
^
/opt/ncnn/tools/quantize/ncnn2table.cpp:753:63: error: 'has' is a protected member of
'cv::CommandLineParser'
if (!parser.has("param") || !parser.has("bin") || !parser.has("images") || !parser.has("...
^
/usr/local/Cellar/opencv@2/2.4.13.7_5/include/opencv2/core/core.hpp:4818:10: note: declared
protected here
bool has(const std::string& keys);
^
/opt/ncnn/tools/quantize/ncnn2table.cpp:753:56: error: 'this' argument to member function 'has' has
type 'const cv::CommandLineParser', but function is not marked const
if (!parser.has("param") || !parser.has("bin") || !parser.has("images") || !parser.has("...
^~
/usr/local/Cellar/opencv@2/2.4.13.7_5/include/opencv2/core/core.hpp:4818:10: note: 'has' declared
here
bool has(const std::string& keys);
^
/opt/ncnn/tools/quantize/ncnn2table.cpp:753:88: error: 'has' is a protected member of
'cv::CommandLineParser'
if (!parser.has("param") || !parser.has("bin") || !parser.has("images") || !parser.has("outp...
^
/usr/local/Cellar/opencv@2/2.4.13.7_5/include/opencv2/core/core.hpp:4818:10: note: declared
protected here
bool has(const std::string& keys);
^
/opt/ncnn/tools/quantize/ncnn2table.cpp:753:81: error: 'this' argument to member function 'has' has
type 'const cv::CommandLineParser', but function is not marked const
if (!parser.has("param") || !parser.has("bin") || !parser.has("images") || !parser.has("outp...
^~
/usr/local/Cellar/opencv@2/2.4.13.7_5/include/opencv2/core/core.hpp:4818:10: note: 'has' declared
here
bool has(const std::string& keys);
^
/opt/ncnn/tools/quantize/ncnn2table.cpp:753:113: error: 'has' is a protected member of
'cv::CommandLineParser'
...|| !parser.has("bin") || !parser.has("images") || !parser.has("output") || !parser.has("mean...
^
/usr/local/Cellar/opencv@2/2.4.13.7_5/include/opencv2/core/core.hpp:4818:10: note: declared
protected here
bool has(const std::string& keys);
^
/opt/ncnn/tools/quantize/ncnn2table.cpp:753:106: error: 'this' argument to member function 'has' has
type 'const cv::CommandLineParser', but function is not marked const
...|| !parser.has("bin") || !parser.has("images") || !parser.has("output") || !parser.has("mean...
^~
/usr/local/Cellar/opencv@2/2.4.13.7_5/include/opencv2/core/core.hpp:4818:10: note: 'has' declared
here
bool has(const std::string& keys);
^
/opt/ncnn/tools/quantize/ncnn2table.cpp:753:136: error: 'has' is a protected member of
'cv::CommandLineParser'
...|| !parser.has("images") || !parser.has("output") || !parser.has("mean") || !parser.has("nor...
^
/usr/local/Cellar/opencv@2/2.4.13.7_5/include/opencv2/core/core.hpp:4818:10: note: declared
protected here
bool has(const std::string& keys);
^
/opt/ncnn/tools/quantize/ncnn2table.cpp:753:129: error: 'this' argument to member function 'has' has
type 'const cv::CommandLineParser', but function is not marked const
...|| !parser.has("images") || !parser.has("output") || !parser.has("mean") || !parser.has("nor...
^~
/usr/local/Cellar/opencv@2/2.4.13.7_5/include/opencv2/core/core.hpp:4818:10: note: 'has' declared
here
bool has(const std::string& keys);
^
/opt/ncnn/tools/quantize/ncnn2table.cpp:756:16: error: no member named 'printMessage' in
'cv::CommandLineParser'
parser.printMessage();
~~ ^
/opt/ncnn/tools/quantize/ncnn2table.cpp:761:50: error: no matching member function for call to 'get'
const std::string image_folder_path = parser.get("images");
~^~~~~
/usr/local/Cellar/opencv@2/2.4.13.7_5/include/opencv2/core/core.hpp:4801:9: note: candidate function
template not viable: 'this' argument has type 'const cv::CommandLineParser', but method is not
marked const
_Tp get(const std::string& name, bool space_delete=true)
^
/opt/ncnn/tools/quantize/ncnn2table.cpp:762:53: error: no matching member function for call to 'get'
const std::string ncnn_param_file_path = parser.get("param");
~^~~~~
/usr/local/Cellar/opencv@2/2.4.13.7_5/include/opencv2/core/core.hpp:4801:9: note: candidate function
template not viable: 'this' argument has type 'const cv::CommandLineParser', but method is not
marked const
_Tp get(const std::string& name, bool space_delete=true)
^
/opt/ncnn/tools/quantize/ncnn2table.cpp:763:51: error: no matching member function for call to 'get'
const std::string ncnn_bin_file_path = parser.get("bin");
~^~~~~
/usr/local/Cellar/opencv@2/2.4.13.7_5/include/opencv2/core/core.hpp:4801:9: note: candidate function
template not viable: 'this' argument has type 'const cv::CommandLineParser', but method is not
marked const
_Tp get(const std::string& name, bool space_delete=true)
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
[ 96%] Building CXX object tests/CMakeFiles/test_softmax.dir/test_softmax.cpp.o

@sebastianfelipe hii
I have used opencv 4.1
I see your version is opencv@2/2.4.13.7_5
that may be the issue?

Probably that's the problem, but in the lasts versions it wouldn't be a problem to compile it, probably it is necessary have a check before the make install step, there's no error when CMake is used. After make git pull I found all these errors. With the last release, everything is working.

you can install opencv real fast on ubantu with learnopencv git repo script

I'm on OSX. Gonna change that version. Thanks.

Cannot find the version 4.1 directly, only 4.2, and there still have problems. I think the lasts commits have compatibility issues, I already linked the PKG_CONFIG_PATH and everything, it is compiling with version 4.2.

/usr/local/Cellar/opencv/4.2.0_1/include/opencv4/opencv2/core/mat.hpp:1010:29: error: no template
named 'initializer_list' in namespace 'std'
explicit Mat(const std::initializer_list<_Tp> list);
~^
/usr/local/Cellar/opencv/4.2.0_1/include/opencv4/opencv2/core/mat.hpp:1014:52: error: no template
named 'initializer_list' in namespace 'std'
template explicit Mat(const std::initializer_list sizes, const std::i...
~^
/usr/local/Cellar/opencv/4.2.0_1/include/opencv4/opencv2/core/mat.hpp:1014:92: error: no template
named 'initializer_list' in namespace 'std'
..._Tp> explicit Mat(const std::initializer_list sizes, const std::initializer_list<_Tp> l...
~^
/usr/local/Cellar/opencv/4.2.0_1/include/opencv4/opencv2/core/mat.hpp:2225:15: error: no template
named 'initializer_list' in namespace 'std'
Mat_(std::initializer_list<_Tp> values);
~^
fatal error: too many errors emitted, stopping now [-ferror-limit=]

I think you should do a compatibility check before (at the CMAKE step possibly) to avoid this kind of issues.

solved:
by adding following to cmakelist
set (CMAKE_CXX_STANDARD 11)

This was the solution for the last issue that happened to me. It works in version 4.2.

Thanks.

set (CMAKE_CXX_STANDARD 11)

You saved my day, God bless you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Abel119 picture Abel119  ·  4Comments

kame-lqm picture kame-lqm  ·  4Comments

zsliaoming picture zsliaoming  ·  3Comments

mychina75 picture mychina75  ·  4Comments

lovehuanhuan picture lovehuanhuan  ·  3Comments