起因: 测试yolov5在本地电脑上的速度,输入640*640的图像,推理时间需要100ms左右,不正常
切换到conda环境下,发现安装了onnxruntime 以及onnxruntime-gpu
self.net = ort.InferenceSession(model_pb_path, providers=['CUDAExecutionProvider'])
首先是直接
pip uninstall onnxruntime
提示:AttributeError: module ‘onnxruntime’ has no attribute ‘InferenceSession’
需要把onnxruntime-gpu卸载掉
最后重新安装
pip install onnxruntime-gpu
运行发现时间只有30ms