Skip to content

Commit

Permalink
Merge pull request #146 from nateraw/onnx-gpu
Browse files Browse the repository at this point in the history
use cuda with onnx if available
  • Loading branch information
psobot authored Nov 4, 2024
2 parents 9991303 + b7e349d commit 53f6738
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion basic_pitch/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@ def __init__(self, model_path: Union[pathlib.Path, str]):
present.append("ONNX")
try:
self.model_type = Model.MODEL_TYPES.ONNX
self.model = ort.InferenceSession(str(model_path), providers=["CPUExecutionProvider"])
providers = ["CPUExecutionProvider"]
if "CUDAExecutionProvider" in ort.get_available_providers():
providers.insert(0, "CUDAExecutionProvider")
self.model = ort.InferenceSession(str(model_path), providers=providers)
return
except Exception as e:
if str(model_path).endswith(".onnx"):
Expand Down

0 comments on commit 53f6738

Please sign in to comment.