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

error about<include>"onnxruntime_cxx_api.h" #17939

Closed
Yiminglii opened this issue Oct 13, 2023 · 6 comments
Closed

error about<include>"onnxruntime_cxx_api.h" #17939

Yiminglii opened this issue Oct 13, 2023 · 6 comments
Labels
ep:CUDA issues related to the CUDA execution provider

Comments

@Yiminglii
Copy link

Yiminglii commented Oct 13, 2023

Describe the issue

I got an error when try to include "onnxruntime_cxx_api.h":

g++ src/main.cpp -o demo lib/libonnxruntime.so.1.16.1 -I include/ -std=c++11

In file included from include/onnxruntime_cxx_api.h:27:0,
from src/main.cpp:3:
include/onnxruntime_float16.h: In static member function ‘static constexpr uint16_t onnxruntime_float16::Float16Impl::ToUint16Impl(float)’:
include/onnxruntime_float16.h:252:50: warning: narrowing conversion of ‘(255 << 23)’ from ‘int’ to ‘unsigned int’ inside { } [-Wnarrowing]
constexpr detail::float32_bits f32infty = {255 << 23};
^
include/onnxruntime_float16.h:254:79: warning: narrowing conversion of ‘((((127 - 15) + (23 - 10)) + 1) << 23)’ from ‘int’ to ‘unsigned int’ inside { } [-Wnarrowing]
constexpr detail::float32_bits denorm_magic = {((127 - 15) + (23 - 10) + 1) << 23};
^
include/onnxruntime_float16.h: In member function ‘float onnxruntime_float16::Float16Impl::ToFloatImpl() const’:
include/onnxruntime_float16.h:297:47: warning: narrowing conversion of ‘(113 << 23)’ from ‘int’ to ‘unsigned int’ inside { } [-Wnarrowing]
constexpr detail::float32_bits magic = {113 << 23};
^
In file included from src/main.cpp:3:0:
include/onnxruntime_cxx_api.h: In constructor ‘constexpr Ort::Float16_t::Float16_t(uint16_t)’:
include/onnxruntime_cxx_api.h:171:64: error: constexpr constructor does not have empty body
constexpr explicit Float16_t(uint16_t v) noexcept { val = v; }
^
include/onnxruntime_cxx_api.h: In static member function ‘static constexpr Ort::Float16_t Ort::Float16_t::FromBits(uint16_t)’:
include/onnxruntime_cxx_api.h:186:83: error: call to non-constexpr function ‘Ort::Float16_t::Float16_t(uint16_t)’
constexpr static Float16_t FromBits(uint16_t v) noexcept { return Float16_t(v); }
^
In file included from include/onnxruntime_cxx_api.h:27:0,
from src/main.cpp:3:
include/onnxruntime_float16.h: In instantiation of ‘static constexpr uint16_t onnxruntime_float16::Float16Impl::ToUint16Impl(float) [with Derived = Ort::Float16_t; uint16_t = short unsigned int]’:
include/onnxruntime_cxx_api.h:192:54: required from here
include/onnxruntime_float16.h:293:1: error: body of constexpr function ‘static constexpr uint16_t onnxruntime_float16::Float16Impl::ToUint16Impl(float) [with Derived = Ort::Float16_t; uint16_t = short unsigned int]’ not a return-statement
}
^
In file included from src/main.cpp:3:0:
include/onnxruntime_cxx_api.h: In constructor ‘constexpr Ort::BFloat16_t::BFloat16_t(uint16_t)’:
include/onnxruntime_cxx_api.h:315:65: error: constexpr constructor does not have empty body
constexpr explicit BFloat16_t(uint16_t v) noexcept { val = v; }
^
include/onnxruntime_cxx_api.h: In static member function ‘static constexpr Ort::BFloat16_t Ort::BFloat16_t::FromBits(uint16_t)’:
include/onnxruntime_cxx_api.h:327:85: error: call to non-constexpr function ‘Ort::BFloat16_t::BFloat16_t(uint16_t)’
static constexpr BFloat16_t FromBits(uint16_t v) noexcept { return BFloat16_t(v); }
^
include/onnxruntime_cxx_api.h: At global scope:
include/onnxruntime_cxx_api.h:1168:93: warning: ‘deprecated’ attribute directive ignored [-Wattributes]
[[deprecated("use GetShape()")]] void GetDimensions(int64_t* values, size_t values_count) const; ///< Wraps OrtApi::GetDimensions
^
src/main.cpp: In function ‘int main()’:
src/main.cpp:38:58: warning: ignoring return value of function declared with attribute warn_unused_result [-Wunused-result]
g_ort->CreateEnv(ORT_LOGGING_LEVEL_WARNING, "test", &env);
^
src/main.cpp:42:46: warning: ignoring return value of function declared with attribute warn_unused_result [-Wunused-result]
g_ort->CreateSessionOptions(&session_options);
^
src/main.cpp:45:66: warning: ignoring return value of ‘OrtStatus* OrtSessionOptionsAppendExecutionProvider_CUDA(OrtSessionOptions*, int)’, declared with attribute warn_unused_result [-Wunused-result]
OrtSessionOptionsAppendExecutionProvider_CUDA(session_options, 0); //use CUDA,注释则为CPU
^
src/main.cpp:56:73: warning: ignoring return value of function declared with attribute warn_unused_result [-Wunused-result]
g_ort->CreateSession(env, model_path.c_str(), session_options, &session);
^
src/main.cpp:82:135: warning: ignoring return value of function declared with attribute warn_unused_result [-Wunused-result]
g_ort->Run(session, NULL, inputNames, (const OrtValue* const*)&input_tensor, inputNodeNum, outputNames, outputNodeNum, &output_tensor);

To reproduce

Centos7
g++ (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
onnxruntime-linux-x64-gpu-1.16.1

Urgency

No response

Platform

Linux

OS Version

centos7

ONNX Runtime Installation

Released Package

ONNX Runtime Version or Commit ID

onnxruntime-linux-x64-gpu-1.16.1

ONNX Runtime API

C++

Architecture

X64

Execution Provider

CUDA

Execution Provider Library Version

No response

@github-actions github-actions bot added the ep:CUDA issues related to the CUDA execution provider label Oct 13, 2023
@vamoslc
Copy link

vamoslc commented Oct 24, 2023

你好 请问是怎么解决的?

@Yiminglii
Copy link
Author

你好 请问是怎么解决的?

是编译器的问题,需要用C++14编译 :-std=c++14

@vamoslc
Copy link

vamoslc commented Oct 24, 2023

好的解决了 非常感谢!

@acechengwang
Copy link

In file included from src/main.cpp:3:0:
include/onnxruntime_cxx_api.h: In constructor ‘constexpr Ort::BFloat16_t::BFloat16_t(uint16_t)’:
include/onnxruntime_cxx_api.h:315:65: error: constexpr constructor does not have empty body
constexpr explicit BFloat16_t(uint16_t v) noexcept { val = v; }

您好,这个问题怎么解决

@Dadoou
Copy link

Dadoou commented Jun 10, 2024

In file included from src/main.cpp:3:0: include/onnxruntime_cxx_api.h: In constructor ‘constexpr Ort::BFloat16_t::BFloat16_t(uint16_t)’: include/onnxruntime_cxx_api.h:315:65: error: constexpr constructor does not have empty body constexpr explicit BFloat16_t(uint16_t v) noexcept { val = v; }

您好,这个问题怎么解决

You may try to update your g++

@segu-L
Copy link

segu-L commented Jul 3, 2024

In file included from src/main.cpp:3:0: include/onnxruntime_cxx_api.h: In constructor ‘constexpr Ort::BFloat16_t::BFloat16_t(uint16_t)’: include/onnxruntime_cxx_api.h:315:65: error: constexpr constructor does not have empty body constexpr explicit BFloat16_t(uint16_t v) noexcept { val = v; }
您好,这个问题怎么解决

You may try to update your g++

Thank you, it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ep:CUDA issues related to the CUDA execution provider
Projects
None yet
Development

No branches or pull requests

5 participants