遇到ValueError: This ORT build has [‘TensorrtExecutionProvider‘, ‘CUDAExecutionProvider‘, ‘CPUExecutio

遇到ValueError: This ORT build has ['TensorrtExecutionProvider', 'CUDAExecutionProvider', 'CPUExecutio

  • 问题描述:
  • 解决方法一:修改model_zoo.py
  • 解决方法二:0

问题描述:

Traceback (most recent call last):
File “test_video_swapsingle.py”, line 58, in
app = Face_detect_crop(name=‘antelope’, root=‘./insightface_func/models’)
File “/mnt/SSD_480G/zhouzikang/SimSwap/insightface_func/face_detect_crop_single.py”, line 40, in init
model = model_zoo.get_model(onnx_file)
File “/home/zhouzikang/anaconda3/envs/simswap/lib/python3.6/site-packages/insightface/model_zoo/model_zoo.py”, line 56, in get_model
model = router.get_model()
File “/home/zhouzikang/anaconda3/envs/simswap/lib/python3.6/site-packages/insightface/model_zoo/model_zoo.py”, line 23, in get_model
session = onnxruntime.InferenceSession(self.onnx_file, None)

File “/home/zhouzikang/anaconda3/envs/simswap/lib/python3.6/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py”, line 335, in init
self._create_inference_session(providers, provider_options, disabled_optimizers)
File “/home/zhouzikang/anaconda3/envs/simswap/lib/python3.6/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py”, line 364, in _create_inference_session
“onnxruntime.InferenceSession(…, providers={}, …)”.format(available_providers))
ValueError: This ORT build has [‘TensorrtExecutionProvider’, ‘CUDAExecutionProvider’, ‘CPUExecutionProvider’] enabled. Since ORT 1.9, you are required to explicitly set the providers parameter when instantiating InferenceSession. For example, onnxruntime.InferenceSession(…, providers=[‘TensorrtExecutionProvider’, ‘CUDAExecutionProvider’, ‘CPUExecutionProvider’], …)

解决方法一:修改model_zoo.py

我是能够通过更改/home/zhouzikang/anaconda3/envs/simswap/lib/python3.6/site-packages/insightface/model_zoo/model_zoo.py的23行,来修复此错误。
从:

session = onnxruntime.InferenceSession(self.onnx_file, None)

修改为:

session = onnxruntime.InferenceSession(self.onnx_file, None, providers=['CUDAExecutionProvider', 'CPUExecutionProvider'])

解决方法二:0

你可能感兴趣的:(霸哥(BUG)日记,python,linux,开发语言,学习,算法)