-
Notifications
You must be signed in to change notification settings - Fork 132
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
refactor(wrapper): refactor the cuda setting #176
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## dev #176 +/- ##
==========================================
- Coverage 86.44% 86.32% -0.12%
==========================================
Files 80 80
Lines 3762 3760 -2
==========================================
- Hits 3252 3246 -6
- Misses 510 514 +4
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
|
||
for _ in range(roll_out_step): | ||
act = act_fn() | ||
next_obs, reward, cost, terminated, truncated, info = self.step(act) |
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.
in all loop of roll_out_step
, use same act
? it seem like a bug, we must consider the situation roll_out_step
!= 1
@@ -92,7 +92,7 @@ def __init__(self, env_id: str, num_envs: int = 1, **kwargs) -> None: | |||
def step( | |||
self, action: torch.Tensor | |||
) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor, Dict]: | |||
obs, reward, cost, terminated, truncated, info = self._env.step(action) | |||
obs, reward, cost, terminated, truncated, info = self._env.step(action.cpu().numpy()) |
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.
use action.detach().cpu().numpy()
omnisafe/envs/core.py
Outdated
@@ -217,16 +218,25 @@ def __getattr__(self, name: str) -> Any: | |||
def step( | |||
self, action: torch.Tensor | |||
) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor, Dict]: | |||
return self._env.step(action) | |||
obs, reward, cost, terminated, truncated, info = self._env.step(action) | |||
return ( |
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.
change device only in safety_gymnasium_env.py
please, changing device in Wrapper
could cause multi-calculating in reset
and step
@@ -75,7 +75,9 @@ class SafetyGymnasiumEnv(CMDP): | |||
need_auto_reset_wrapper = False | |||
need_time_limit_wrapper = False | |||
|
|||
def __init__(self, env_id: str, num_envs: int = 1, **kwargs) -> None: | |||
def __init__( | |||
self, env_id: str, num_envs: int = 1, device: torch.device = 'cpu', **kwargs |
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.
device: torch.device = torch.device('cpu')
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.
LGTM.
* refactor(wrapper): refactor the cuda setting * chore: revert train_policy.py * chore: set device in safety_gymnasium_env.py * fix: [pre-commit.ci] auto fixes [...] * fix(safety_gymnasium_env.py): fix device interface --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Description
refactor the cuda setting
Types of changes
What types of changes does your code introduce? Put an
x
in all the boxes that apply:Checklist
Go over all the following points, and put an
x
in all the boxes that apply.If you are unsure about any of these, don't hesitate to ask. We are here to help!
make format
. (required)make lint
. (required)make test
pass. (required)