isaac-sim/IsaacGymEnvs

AssertionError: GlobalHydra is not initialized, use @hydra.main() or call one of the hydra initialization methods first

Opened this issue · 3 comments

Hi!

I started with the following code to initialize a Factory task

import isaacgym
import isaacgymenvs
import torch

num_envs = 2000

envs = isaacgymenvs.make(
    seed=0,
    task="FactoryTaskNutBoltPick",
    num_envs=num_envs,
    headless=False,
    graphics_device_id=0,
    sim_device="cuda:0",
    rl_device="cuda:0",
)
print("Observation space is", envs.observation_space)
print("Action space is", envs.action_space)
obs = envs.reset()
for _ in range(2000):
    random_actions = 2.0 * torch.rand((num_envs,) + envs.action_space.shape, device="cuda:0") - 1.0
    envs.step(random_actions)

and met this error:

Traceback (most recent call last):
  File "/home/xzc/isaac_ws/test_scripts/test.py", line 7, in <module>
    envs = isaacgymenvs.make(
  File "/home/xzc/Documents/IsaacGymEnvs/isaacgymenvs/__init__.py", line 55, in make
    return create_rlgpu_env()
  File "/home/xzc/Documents/IsaacGymEnvs/isaacgymenvs/utils/rlgames_utils.py", line 113, in create_rlgpu_env
    env = isaacgym_task_map[task_name](
  File "/home/xzc/Documents/IsaacGymEnvs/isaacgymenvs/tasks/factory/factory_task_nut_bolt_pick.py", line 54, in __init__
    super().__init__(cfg, rl_device, sim_device, graphics_device_id, headless, virtual_screen_capture, force_render)
  File "/home/xzc/Documents/IsaacGymEnvs/isaacgymenvs/tasks/factory/factory_env_nut_bolt.py", line 53, in __init__
    self._get_env_yaml_params()
  File "/home/xzc/Documents/IsaacGymEnvs/isaacgymenvs/tasks/factory/factory_env_nut_bolt.py", line 69, in _get_env_yaml_params
    self.cfg_env = hydra.compose(config_name=config_path)
  File "/home/xzc/mambaforge/envs/rlgpu/lib/python3.8/site-packages/hydra/compose.py", line 32, in compose
    assert (
AssertionError: GlobalHydra is not initialized, use @hydra.main() or call one of the hydra initialization methods first

I have tried some other tasks and met no errors. What triggers this error? Thanks!

Hello, save problems occur when initialized the Factory and IndustReal tasks.
Have you ever fixed it ? @zichunxx

Sorry, I might fixed if.

in init.py file which defined the function isaacgymens.make(),

line 35:
ori: with initialize(config_path="./cfg")
changed to :
else:
initialize(config_path="./cfg")

I don't know why, but ok to render.
Seems like the sentence(" with ") cant initialize globalhydra in Factory and IndustReal

Hi! @yuzej I haven't used Isaac gym for a while. But thanks so much for giving the solution, I will try it.