Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to compile C++ VAD example #451

Closed
akmitrich opened this issue May 8, 2024 · 3 comments
Closed

Failed to compile C++ VAD example #451

akmitrich opened this issue May 8, 2024 · 3 comments
Assignees
Labels
help wanted Extra attention is needed

Comments

@akmitrich
Copy link

C++ VAD example

You have a great cpp test example for your VAD model. It is provided with clear explanations. In accordance with README I created a Dockerfile:

FROM gcc:12.2.0-bullseye
WORKDIR /root
RUN wget https://github.com/microsoft/onnxruntime/releases/download/v1.12.1/onnxruntime-linux-x64-1.12.1.tgz
RUN tar -xvzf onnxruntime-linux-x64-1.12.1.tgz
COPY silero_vad.onnx .
COPY silero-vad-onnx.cpp .
COPY wav.h .
RUN g++ silero-vad-onnx.cpp -I /root/onnxruntime-linux-x64-1.12.1/include/ -L /root/onnxruntime-linux-x64-1.12.1/lib/ -lonnxruntime  -Wl,-rpath,/root/onnxruntime-linux-x64-1.12.1/lib/ -o test
ENTRYPOINT [ "./test" ]

which is far from being optimal but it is ok for a quick test.

Failed to compile

During compilation it runs into error:

In file included from /usr/local/include/c++/12.2.0/bits/alloc_traits.h:33,                                                                                                                                 
                 from /usr/local/include/c++/12.2.0/ext/alloc_traits.h:34,                                                                                                                                  
                 from /usr/local/include/c++/12.2.0/bits/basic_string.h:39,                                                                                                                                 
                 from /usr/local/include/c++/12.2.0/string:53,                                                                                                                                              
                 from /usr/local/include/c++/12.2.0/bits/locale_classes.h:40,
                 from /usr/local/include/c++/12.2.0/bits/ios_base.h:41,
                 from /usr/local/include/c++/12.2.0/ios:42,
                 from /usr/local/include/c++/12.2.0/ostream:38,
                 from /usr/local/include/c++/12.2.0/iostream:39,
                 from silero-vad-onnx.cpp:1:
/usr/local/include/c++/12.2.0/bits/stl_construct.h: In instantiation of 'void std::_Construct(_Tp*, _Args&& ...) [with _Tp = Ort::Session; _Args = {Ort::Env&, const wchar_t*, Ort::SessionOptions&}]':
/usr/local/include/c++/12.2.0/bits/alloc_traits.h:635:19:   required from 'static void std::allocator_traits<std::allocator<void> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = Ort::Session; _Args = {Ort::Env&, const wchar_t*, Ort::SessionOptions&}; allocator_type = std::allocator<void>]'
/usr/local/include/c++/12.2.0/bits/shared_ptr_base.h:604:39:   required from 'std::_Sp_counted_ptr_inplace<_Tp, _Alloc, _Lp>::_Sp_counted_ptr_inplace(_Alloc, _Args&& ...) [with _Args = {Ort::Env&, const wchar_t*, Ort::SessionOptions&}; _Tp = Ort::Session; _Alloc = std::allocator<void>; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]'
/usr/local/include/c++/12.2.0/bits/shared_ptr_base.h:971:16:   required from 'std::__shared_count<_Lp>::__shared_count(_Tp*&, std::_Sp_alloc_shared_tag<_Alloc>, _Args&& ...) [with _Tp = Ort::Session; _Alloc = std::allocator<void>; _Args = {Ort::Env&, const wchar_t*, Ort::SessionOptions&}; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]'
/usr/local/include/c++/12.2.0/bits/shared_ptr_base.h:1712:14:   required from 'std::__shared_ptr<_Tp, _Lp>::__shared_ptr(std::_Sp_alloc_shared_tag<_Tp>, _Args&& ...) [with _Alloc = std::allocator<void>; _Args = {Ort::Env&, const wchar_t*, Ort::SessionOptions&}; _Tp = Ort::Session; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]'
/usr/local/include/c++/12.2.0/bits/shared_ptr.h:464:59:   required from 'std::shared_ptr<_Tp>::shared_ptr(std::_Sp_alloc_shared_tag<_Tp>, _Args&& ...) [with _Alloc = std::allocator<void>; _Args = {Ort::Env&, const wchar_t*, Ort::SessionOptions&}; _Tp = Ort::Session]'
/usr/local/include/c++/12.2.0/bits/shared_ptr.h:1009:14:   required from 'std::shared_ptr<typename std::enable_if<(! std::is_array< <template-parameter-1-1> >::value), _Tp>::type> std::make_shared(_Args&& ...) [with _Tp = Ort::Session; _Args = {Ort::Env&, const wchar_t*, Ort::SessionOptions&}; typename enable_if<(! is_array< <template-parameter-1-1> >::value), _Tp>::type = Ort::Session]'
silero-vad-onnx.cpp:112:49:   required from here
/usr/local/include/c++/12.2.0/bits/stl_construct.h:119:7: error: no matching function for call to 'Ort::Session::Session(Ort::Env&, const wchar_t*, Ort::SessionOptions&)'
  119 |       ::new((void*)__p) _Tp(std::forward<_Args>(__args)...);
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

With the same error it fails to compile in my local Ubuntu environment with other versions of g++, onnxruntime.

Need some directions

How to deploy Silero VAD model with C++?

@akmitrich akmitrich added the help wanted Extra attention is needed label May 8, 2024
@IntendedConsequence
Copy link

@akmitrich try changing std::wstring to std::string in the example code. Onnxruntime C/C++ api uses wchar_t for paths only on windows.

@akmitrich
Copy link
Author

Thanks a lot. This did help me to build example. Also I have to get rid of L"..." string literals in the source code.

@akmitrich
Copy link
Author

I have run test example for my random audio file.
Test example works perfectly fine for the aforementioned gcc 12.2.0 and onnxruntime 1.12.0.
Even better, it also works as fine for gcc 14.1.0 and recently released onnxruntime 1.18.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants