Skip to content

Commit 6843816

Browse files
committed
Switched to GPU
1 parent ca7c03e commit 6843816

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

gradio_app.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,11 @@ def __init__(self, model_path: str, threshold: float = DEFAULT_THRESHOLD, use_on
8484
if not ONNXRUNTIME_AVAILABLE:
8585
raise ImportError("onnxruntime is required for ONNX models. Install with: pip install onnxruntime")
8686
try:
87-
self.onnx_session = ort.InferenceSession(model_path)
87+
# Configure ONNX session options for stability
88+
sess_options = ort.SessionOptions()
89+
sess_options.intra_op_num_threads = 1 # Avoid threading issues in container
90+
sess_options.inter_op_num_threads = 1
91+
self.onnx_session = ort.InferenceSession(model_path, sess_options)
8892
self.model = None
8993
except Exception as e:
9094
raise RuntimeError(f"Failed to load ONNX model from {model_path}: {str(e)}")
@@ -791,6 +795,7 @@ def create_summary_visualizations(df):
791795
volumes={"/models": model_volume},
792796
timeout=600, # Increased timeout to 10 minutes
793797
container_idle_timeout=300, # Keep container alive for 5 minutes
798+
gpu="any", # Use any available GPU
794799
)
795800
@modal.concurrent(max_inputs=100)
796801
@modal.asgi_app()

0 commit comments

Comments
 (0)