From 9c1ea4fa011a8b64a1f0081edbc10eb14f550252 Mon Sep 17 00:00:00 2001 From: Shivam Kumar Date: Wed, 31 May 2023 09:20:41 +0530 Subject: [PATCH] Fix GPU not being used even when it available On lots of systems onnxruntime doesn't detect GPU unless pytorch is imported before it. So despite having CUDA and CUDNN setup correctly, it is only using CPUExecutionProvider. By importing pytorch first, the issue is fixed. So let's use this until any official solution is available. See: https://stackoverflow.com/questions/75294639/onnxruntime-inference-with-cudnn-on-gpu-only-working-if-pytorch-imported-first --- core/globals.py | 1 + 1 file changed, 1 insertion(+) diff --git a/core/globals.py b/core/globals.py index cbd26c2..dc77baf 100644 --- a/core/globals.py +++ b/core/globals.py @@ -1,3 +1,4 @@ +import torch import onnxruntime use_gpu = False