-
Notifications
You must be signed in to change notification settings - Fork 157
Dynamic session providers for onnxruntime #983
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,9 +20,12 @@ | |
|
|
||
| import mujoco | ||
| import numpy as np | ||
| import onnxruntime as rt # type: ignore[import-untyped] | ||
| import onnxruntime as ort # type: ignore[import-untyped] | ||
|
|
||
| from dimos.simulation.mujoco.input_controller import InputController | ||
| from dimos.utils.logging_config import setup_logger | ||
|
|
||
| logger = setup_logger() | ||
|
|
||
|
|
||
| class OnnxController(ABC): | ||
|
|
@@ -37,7 +40,8 @@ def __init__( | |
| drift_compensation: list[float] | None = None, | ||
| ) -> None: | ||
| self._output_names = ["continuous_actions"] | ||
| self._policy = rt.InferenceSession(policy_path, providers=["CPUExecutionProvider"]) | ||
| self._policy = ort.InferenceSession(policy_path, providers=ort.get_available_providers()) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The change from hardcoded Issues:
Recommendation: self._policy = ort.InferenceSession(policy_path, providers=ort.get_available_providers())
actual_providers = self._policy.get_providers()
# Log: f"Initialized ONNX policy with providers: {actual_providers}"This would help users understand which execution provider is being used and debug any performance or behavior differences. Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
||
| logger.info(f"Loaded policy: {policy_path} with providers: {self._policy.get_providers()}") | ||
|
|
||
| self._action_scale = action_scale | ||
| self._default_angles = default_angles | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding logging to show which execution provider is actually being used after initialization. This would help with debugging and verifying that GPU acceleration is working when available.
Similar to the pattern used in
dimos/agents_deprecated/memory/image_embedding.py:89-91:This is especially useful since
get_available_providers()returns all available providers, but the InferenceSession may only successfully initialize with a subset of them.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!