Closed xinsuinizhuan closed 3 years ago
0xC0000005 means one or more arguments you are trying to use is invalid. I suspect is is the model path. The debugger should should you better than my guess. You do not have new Ort::Session so you do not need to delete it. You can just instantiate it on the stack. Also try to catch the exceptions in main() and print a meaningful message in case a C++ exception is throw, instead of just terminating.
OK.Trank you. It is the path of model. it works now.
Describe the bug I want to use the onnxruntime with gpu forward, so use the below code : ort_env = Ort::Env(ORT_LOGGING_LEVEL_ERROR, log_id); // 0. session options Ort::SessionOptions session_options; session_options.SetIntraOpNumThreads(num_threads); //session_options.SetGraphOptimizationLevel(GraphOptimizationLevel::ORT_ENABLE_ALL); session_options.SetGraphOptimizationLevel(ORT_ENABLE_BASIC); session_options.SetLogSeverityLevel(4);
ifdef USE_CUDA
//OrtCUDAProviderOptions provider_options; // C接口 //session_options.AppendExecutionProvider_CUDA(provider_options); OrtCUDAProviderOptions options; options.device_id = 0; options.arena_extend_strategy = 0; options.cudnn_conv_algo_search = OrtCudnnConvAlgoSearch::EXHAUSTIVE; options.do_copy_in_default_stream = 1; session_options.AppendExecutionProvider_CUDA(options);
endif
// 1. session ort_session = new Ort::Session(ort_env, onnx_path, session_options); but when it run ort_session = new Ort::Session(ort_env, onnx_path, session_options); , it break! 0x00007FFB0AF2ACFF (onnxruntime_providers_cuda.dll)处(位于 yolox_demo.exe 中)引发的异常: 0xC0000005: 读取位置 0x000000000000009C 时发生访问冲突。
System information OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Windows 10 ONNX Runtime installed from (source or binary): https://github.com/microsoft/onnxruntime/releases ONNX Runtime version: 1.8.1 Visual Studio version (if applicable):16.10.4 GCC/Compiler version (if compiling from source): NA CUDA/cuDNN version: cuda_11.0.3 / cudnn-11.0-windows-x64-v8.0.2.39 GPU model and memory: GeForce RTX 3060 Laptop
To Reproduce: void xxx::initialize_handler() { ort_env = Ort::Env(ORT_LOGGING_LEVEL_ERROR, log_id); // 0. session options Ort::SessionOptions session_options; session_options.SetIntraOpNumThreads(num_threads); //session_options.SetGraphOptimizationLevel(GraphOptimizationLevel::ORT_ENABLE_ALL); session_options.SetGraphOptimizationLevel(ORT_ENABLE_BASIC); session_options.SetLogSeverityLevel(4);
ifdef USE_CUDA
//OrtCUDAProviderOptions provider_options; // C接口 //session_options.AppendExecutionProvider_CUDA(provider_options); OrtCUDAProviderOptions options; options.device_id = 0; options.arena_extend_strategy = 0; options.cudnn_conv_algo_search = OrtCudnnConvAlgoSearch::EXHAUSTIVE; options.do_copy_in_default_stream = 1; session_options.AppendExecutionProvider_CUDA(options);
endif
// 1. session ort_session = new Ort::Session(ort_env, onnx_path, session_options);
Ort::AllocatorWithDefaultOptions allocator; // 2. input name & input dims input_name = ort_session->GetInputName(0, allocator); input_node_names.resize(1); input_node_names[0] = input_name; // 3. type info. Ort::TypeInfo type_info = ort_session->GetInputTypeInfo(0); auto tensor_info = type_info.GetTensorTypeAndShapeInfo(); input_tensor_size = 1; input_node_dims = tensor_info.GetShape(); for (unsigned int i = 0; i < input_node_dims.size(); ++i) input_tensor_size *= input_node_dims.at(i); input_values_handler.resize(input_tensor_size); // 4. output names & output dimms num_outputs = ort_session->GetOutputCount(); output_node_names.resize(num_outputs); for (unsigned int i = 0; i < num_outputs; ++i) { output_node_names[i] = ort_session->GetOutputName(i, allocator); Ort::TypeInfo output_type_info = ort_session->GetOutputTypeInfo(i); auto output_tensor_info = output_type_info.GetTensorTypeAndShapeInfo(); auto output_dims = output_tensor_info.GetShape(); output_node_dims.push_back(output_dims); }
if LITEORT_DEBUG
this->print_debug_string();
endif
}