pytorch / pytorch/rl

[BUG] Failing to Create Isaac Gym Environments

Open
#2,292 0 comments 0 reactions 1 assignee View on GitHub

@vmoens is already working on this.

Since Jul 14, 2024.

bug
Dominant language
Python
Stars
3.6k
Forks
484
Avg merge
1d 1h
Merged PRs (30d)
207

Description

Describe the bug

The lateset stable relase (0.4) fails to create Isaac Gym Preview 4 environments.

To Reproduce

import isaacgym
from torchrl.envs import IsaacGymEnv
env = IsaacGymEnv(task="Ant", num_envs=2000, device="cuda:0")
+++ Using GPU PhysX
Physics Engine: PhysX
Physics Device: cuda:0
GPU Pipeline: enabled
num envs 2000 env spacing 5
/home/lyq/Developer/isaacgym_workspace/IsaacGymEnvs/isaacgymenvs/tasks/ant.py:151: DeprecationWarning: an integer is required (got type isaacgym._bindings.linux-x86_64.gym_38.DofDriveMode).  Implicit conversion to integers using __int__ is deprecated, and may be removed in a future version of Python.
  asset_options.default_dof_drive_mode = gymapi.DOF_MODE_NONE
/home/lyq/mambaforge/envs/rlgpu/lib/python3.8/site-packages/torchrl/envs/libs/isaacgym.py:49: UserWarning: IsaacGym environment support is an experimental feature that may change in the future.
  warnings.warn(
/home/lyq/mambaforge/envs/rlgpu/lib/python3.8/site-packages/torchrl/envs/common.py:2989: DeprecationWarning: Your wrapper was not given a device. Currently, this value will default to 'cpu'. From v0.5 it will default to `None`. With a device of None, no device casting is performed and the resulting tensordicts are deviceless. Please set your device accordingly.
  warnings.warn(
Traceback (most recent call last):
  File "trl.py", line 4, in <module>
    env = IsaacGymEnv(task="Ant", num_envs=2000, device="cuda:0")
  File "/home/lyq/mambaforge/envs/rlgpu/lib/python3.8/site-packages/torchrl/envs/libs/gym.py", line 543, in __call__
    instance: GymWrapper = super().__call__(*args, **kwargs)
  File "/home/lyq/mambaforge/envs/rlgpu/lib/python3.8/site-packages/torchrl/envs/common.py", line 175, in __call__
    instance: EnvBase = super().__call__(*args, **kwargs)
  File "/home/lyq/mambaforge/envs/rlgpu/lib/python3.8/site-packages/torchrl/envs/libs/isaacgym.py", line 188, in __init__
    super().__init__(envs, **kwargs)
  File "/home/lyq/mambaforge/envs/rlgpu/lib/python3.8/site-packages/torchrl/envs/libs/isaacgym.py", line 53, in __init__
    super().__init__(
  File "/home/lyq/mambaforge/envs/rlgpu/lib/python3.8/site-packages/torchrl/envs/libs/gym.py", line 729, in __init__
    super().__init__(**kwargs)
  File "/home/lyq/mambaforge/envs/rlgpu/lib/python3.8/site-packages/torchrl/envs/common.py", line 3019, in __init__
    self._make_specs(self._env)  # writes the self._env attribute
  File "/home/lyq/mambaforge/envs/rlgpu/lib/python3.8/site-packages/torchrl/envs/libs/isaacgym.py", line 61, in _make_specs
    super()._make_specs(env, batch_size=self.batch_size)
  File "/home/lyq/mambaforge/envs/rlgpu/lib/python3.8/site-packages/torchrl/envs/libs/gym.py", line 962, in _make_specs
    observation_spec = CompositeSpec(
  File "/home/lyq/mambaforge/envs/rlgpu/lib/python3.8/site-packages/torchrl/data/tensor_specs.py", line 3647, in __init__
    self.set(key, value)
  File "/home/lyq/mambaforge/envs/rlgpu/lib/python3.8/site-packages/torchrl/data/tensor_specs.py", line 3630, in set
    raise ValueError(
ValueError: The shape of the spec and the CompositeSpec mismatch: the first 2 dimensions should match but got spec.shape=torch.Size([60]) and CompositeSpec.shape=torch.Size([2000, 2000]).

Expected behavior

The example should be executed without error.

System info

torchrl and tensordict are installed using pip in a conda environment with python=3.8.

import torchrl, numpy, sys
print(torchrl.__version__, numpy.__version__, sys.version, sys.platform)
0.4.0 1.19.5 3.8.19 | packaged by conda-forge | (default, Mar 20 2024, 12:47:35) 
[GCC 12.3.0] linux

Additional context

I saw some bug fixes regarding the wrapper, but encountered other errors when trying the newest version after installing using python setup.py develop.

Checklist

  • I have checked that there is no similar issue in the repo (required)
  • I have read the documentation (required)
  • I have provided a minimal working example to reproduce the bug (required)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.