Skip to content

Commit

Permalink
Only allow CUDAExecutionProvider if available
Browse files Browse the repository at this point in the history
  • Loading branch information
wkentaro committed Feb 12, 2024
1 parent e896da9 commit e0af059
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion osam/_models/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ def __init__(self):
try:
# Try to use all of the available providers e.g., cuda, tensorrt.
if providers is None:
providers = onnxruntime.get_available_providers()
if "CUDAExecutionProvider" in onnxruntime.get_available_providers():
providers = ["CUDAExecutionProvider", "CPUExecutionProvider"]
else:
providers = ["CPUExecutionProvider"]
# Suppress all the error messages from the missing providers.
with _contextlib.suppress():
inference_session = onnxruntime.InferenceSession(
Expand Down

0 comments on commit e0af059

Please sign in to comment.