项目场景:
onnx模型测试,遇到一下问题…
问题描述
ignificantly reduce device memory usage. See `CUDA_MODULE_LOADING` in https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#env-vars
Traceback (most recent call last):
File "/home/lewele001/anaconda3/envs/Pipeline_py37/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/home/lewele001/anaconda3/envs/Pipeline_py37/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/lewele001/.vscode/extensions/ms-python.python-2022.18.2/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/../../debugpy/__main__.py", line 39, in <module>
cli.main()
File "/home/lewele001/.vscode/extensions/ms-python.python-2022.18.2/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 430, in main
run()
File "/home/lewele001/.vscode/extensions/ms-python.python-2022.18.2/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 284, in run_file
runpy.run_path(target, run_name="__main__")
File "/home/lewele001/.vscode/extensions/ms-python.python-2022.18.2/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 322, in run_path
pkg_name=pkg_name, script_name=fname)
File "/home/lewele001/.vscode/extensions/ms-python.python-2022.18.2/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 136, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "/home/lewele001/.vscode/extensions/ms-python.python-2022.18.2/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 124, in _run_code
exec(code, run_globals)
File "/home/lewele001/work/code/deep_learn/dsm_dir/Pipeline/inference.py", line 53, in <module>
stop_demo, img = demo(img, name , args.log, ts_ns)
File "/home/lewele001/work/code/deep_learn/dsm_dir/Pipeline/pipeline.py", line 185, in __call__
dets = self.detect(image)
File "/home/lewele001/work/code/deep_learn/dsm_dir/Pipeline/detection/face_detector.py", line 44, in __call__
onnx_outs = self.onnx_session.run(None, onnx_inputs)
File "/home/lewele001/anaconda3/envs/Pipeline_py37/lib/python3.7/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 192, in run
return self._sess.run(output_names, input_feed, run_options)
onnxruntime.capi.onnxruntime_pybind11_state.InvalidArgument: [ONNXRuntimeError] : 2 : INVALID_ARGUMENT : Got invalid dimensions for input: image for the following indices
index: 2 Got: 270 Expected: 200
index: 3 Got: 432 Expected: 320
Please fix either the inputs or the model.
QLibraryPrivate::unload succeeded on "/home/lewele001/anaconda3/envs/Pipeline_py37/plugins/platforminputcontexts/libcomposeplatforminputcontextplugin.so"
QLibraryPrivate::unload succeeded on "/home/lewele001/anaconda3/envs/Pipeline_py37/plugins/xcbglintegrations/libqxcb-glx-integration.so"
QLibraryPrivate::unload succeeded on "/home/lewele001/anaconda3/envs/Pipeline_py37/plugins/platforms/libqxcb.so"
QLibraryPrivate::unload succeeded on "Xcursor" (faked)
Unexpected Internal Error: [virtualMemoryBuffer.cpp::~StdVirtualMemoryBufferImpl::105] Error Code 1: Cuda Runtime (driver shutting down)
Unexpected Internal Error: [virtualMemoryBuffer.cpp::~StdVirtualMemoryBufferImpl::105] Error Code 1: Cuda Runtime (driver shutting down)
原因分析:
onnxruntime.capi.onnxruntime_pybind11_state.InvalidArgument: [ONNXRuntimeError] : 2 : INVALID_ARGUMENT : Got invalid dimensions for input: image for the following indices
index: 2 Got: 270 Expected: 200
index: 3 Got: 432 Expected: 320
Please fix either the inputs or the model.
这个错,意思很简单,意思是 onnx 模型的输入是
一个维度是270,一个维度是200,所以是INVALID ARGUMENT(无效的输入)
解决方案:
输入图像尺寸和模型不匹配,调整图片size,解决问你。