ARISE-Initiative / robomimic

robomimic: A Modular Framework for Robot Learning from Demonstration
MIT License
592 stars 181 forks source link

module 'robosuite' has no attribute 'make' #159

Closed luccachiang closed 3 months ago

luccachiang commented 3 months ago

Hi, I'm using the robocasa branch, but got the AttributeError in this line: https://github.com/ARISE-Initiative/robomimic/blob/2e32a25f9aea6ba486de39e1d8d353244fe8a039/robomimic/envs/env_robosuite.py#L94

Is there something wrong with this branch?

snasiriany commented 3 months ago

Hi @luccachiang can you please print the full stack trace, and let me know all the steps to reproduce the issue?

luccachiang commented 3 months ago

Thanks for your prompt response. @snasiriany I believe the following steps are the minimum to reproduce the error.

  1. Install following https://github.com/robocasa/robocasa#installation. Note that insterestingly after installing robosuite (step 3), I do not have the make attribute error. However, after installing robocasa (step 4), I cannot import 'make'.

    image
  2. Install following https://github.com/ARISE-Initiative/robomimic/tree/robocasa#installation

  3. Use CLI python in this conda env to test robosuite

    from robosuite import make

Based on the steps above, I can temporarily solve this problem by re-executing robosuite installation with pip install -e .. Sometimes, it still has the problem with CLI Python. Moreover, when I try to run training scripts with --debug, this error is still there during policy rollout in the env.

I am using this command python /home/lucas/robocasa/robomimic/robomimic/scripts/train.py --config /home/lucas/robocasa/robomimic/autogen_configs/bc/bc/robocasa/im/06-12-test/06-12-24-11-21-08/json/seed_123_ds_OpenSingleDoor.json --debug

Getting this error stack.

Epoch 0 Memory Usage: 2688 MB

  0%|          | 0/3 [00:00<?, ?it/s]ObservationKeyToModalityDict: pad_mask not found, adding pad_mask to mapping with assumed low_dim modality!
ObservationKeyToModalityDict: lang_emb not found, adding lang_emb to mapping with assumed low_dim modality!
100%|##########| 3/3 [00:01<00:00,  2.19it/s]
Train Epoch 1
{
    "Cosine_Loss": 0.9224040110905966,
    "L1_Loss": 0.10094895462195079,
    "L2_Loss": 0.20192878941694895,
    "Loss": 0.20192878941694895,
    "Optimizer/policy0_lr": 0.0001,
    "Policy_Grad_Norms": 0.17695442954617077,
    "Time_Data_Loading": 0.005813217163085938,
    "Time_Epoch": 0.025638210773468017,
    "Time_Log_Info": 5.130767822265625e-05,
    "Time_Process_Batch": 9.459654490152994e-05,
    "Time_Train_Batch": 0.01688726743062337
}
/home/lucas/robocasa/robosuite/robosuite/macros.py:53: DeprecationWarning: The 'warn' method is deprecated, use 'warning' instead
  ROBOSUITE_DEFAULT_LOGGER.warn("No private macro file found!")
[robosuite WARNING] No private macro file found! (macros.py:53)
[robosuite WARNING] It is recommended to use a private macro file (macros.py:54)
[robosuite WARNING] To setup, run: python /home/lucas/robocasa/robosuite/scripts/setup_macros.py (macros.py:55)
WARNING: mimicgen environments not imported since mimicgen is not installed!
run failed with error:
module 'robosuite' has no attribute 'make'

Traceback (most recent call last):
  File "/home/lucas/robocasa/robomimic/robomimic/scripts/train.py", line 473, in main
    train(config, device=device)
  File "/home/lucas/robocasa/robomimic/robomimic/scripts/train.py", line 325, in train
    all_rollout_logs, video_paths = TrainUtils.rollout_with_stats(
  File "/home/lucas/robocasa/robomimic/robomimic/utils/train_utils.py", line 527, in rollout_with_stats
    for env, horizon in zip(envs, horizon_list):
  File "/home/lucas/robocasa/robomimic/robomimic/scripts/train.py", line 145, in env_iterator
    env = create_env_helper()
  File "/home/lucas/robocasa/robomimic/robomimic/scripts/train.py", line 133, in create_env_helper
    env = EnvUtils.create_env_from_metadata(**env_kwargs)
  File "/home/lucas/robocasa/robomimic/robomimic/utils/env_utils.py", line 228, in create_env_from_metadata
    env = create_env(
  File "/home/lucas/robocasa/robomimic/robomimic/utils/env_utils.py", line 172, in create_env
    env = env_class(
  File "/home/lucas/robocasa/robomimic/robomimic/envs/env_robosuite.py", line 96, in __init__
    self.env = robosuite.make(self._env_name, **kwargs)
AttributeError: module 'robosuite' has no attribute 'make'

Below is the config I generated.

{
    "algo_name": "bc",
    "experiment": {
        "name": "seed_123_ds_OpenSingleDoor",
        "validate": false,
        "logging": {
            "terminal_output_to_txt": true,
            "log_tb": true,
            "log_wandb": false,
            "wandb_proj_name": "bc_06-12-test_robocasa_im"
        },
        "mse": {},
        "save": {
            "enabled": true,
            "every_n_seconds": null,
            "every_n_epochs": 100,
            "epochs": [],
            "on_best_validation": false,
            "on_best_rollout_return": false,
            "on_best_rollout_success_rate": false
        },
        "epoch_every_n_steps": 500,
        "validation_epoch_every_n_steps": 10,
        "env": null,
        "additional_envs": null,
        "render": false,
        "render_video": true,
        "keep_all_videos": false,
        "video_skip": 5,
        "rollout": {
            "enabled": true,
            "n": 50,
            "horizon": 500,
            "rate": 100,
            "warmstart": 0,
            "terminate_on_success": true
        },
        "env_meta_update_dict": {
            "env_kwargs": {
                "generative_textures": null,
                "scene_split": null,
                "style_ids": null,
                "layout_ids": null,
                "layout_and_style_ids": [
                    [
                        1,
                        1
                    ],
                    [
                        2,
                        2
                    ],
                    [
                        4,
                        4
                    ],
                    [
                        6,
                        9
                    ],
                    [
                        7,
                        10
                    ]
                ],
                "randomize_cameras": false,
                "obj_instance_split": "B"
            }
        }
    },
    "train": {
        "data": [
            {
                "horizon": 500,
                "do_eval": true,
                "filter_key": "50_demos",
                "path": "/home/lucas/robocasa/datasets/v0.1/single_stage/kitchen_doors/OpenSingleDoor/2024-04-24/demo_gentex_im128_randcams.hdf5"
            }
        ],
        "output_dir": "../expdata/robocasa/im/bc/06-12-test",
        "num_data_workers": 5,
        "hdf5_cache_mode": null,
        "hdf5_use_swmr": true,
        "hdf5_load_next_obs": false,
        "hdf5_normalize_obs": false,
        "hdf5_filter_key": null,
        "hdf5_validation_filter_key": null,
        "seq_length": 1,
        "pad_seq_length": true,
        "frame_stack": 1,
        "pad_frame_stack": true,
        "dataset_keys": [
            "actions",
            "rewards",
            "dones"
        ],
        "goal_mode": null,
        "cuda": true,
        "batch_size": 16,
        "num_epochs": 1000,
        "seed": 123,
        "action_config": {
            "actions": {
                "normalization": null
            },
            "action_dict/abs_pos": {
                "normalization": "min_max"
            },
            "action_dict/abs_rot_axis_angle": {
                "normalization": "min_max",
                "format": "rot_axis_angle"
            },
            "action_dict/abs_rot_6d": {
                "normalization": null,
                "format": "rot_6d"
            },
            "action_dict/rel_pos": {
                "normalization": null
            },
            "action_dict/rel_rot_axis_angle": {
                "normalization": null,
                "format": "rot_axis_angle"
            },
            "action_dict/rel_rot_6d": {
                "normalization": null,
                "format": "rot_6d"
            },
            "action_dict/gripper": {
                "normalization": null
            },
            "action_dict/base_mode": {
                "normalization": null
            }
        }
    },
    "algo": {
        "optim_params": {
            "policy": {
                "optimizer_type": "adam",
                "learning_rate": {
                    "initial": 0.0001,
                    "decay_factor": 0.1,
                    "epoch_schedule": [],
                    "scheduler_type": "multistep"
                },
                "regularization": {
                    "L2": 0.0
                }
            }
        },
        "loss": {
            "l2_weight": 1.0,
            "l1_weight": 0.0,
            "cos_weight": 0.0
        },
        "actor_layer_dims": [
            1024,
            1024
        ],
        "gaussian": {
            "enabled": false,
            "fixed_std": false,
            "init_std": 0.1,
            "min_std": 0.01,
            "std_activation": "softplus",
            "low_noise_eval": true
        },
        "gmm": {
            "enabled": false,
            "num_modes": 5,
            "min_std": 0.0001,
            "std_activation": "softplus",
            "low_noise_eval": true
        },
        "vae": {
            "enabled": false,
            "latent_dim": 14,
            "latent_clip": null,
            "kl_weight": 1.0,
            "decoder": {
                "is_conditioned": true,
                "reconstruction_sum_across_elements": false
            },
            "prior": {
                "learn": false,
                "is_conditioned": false,
                "use_gmm": false,
                "gmm_num_modes": 10,
                "gmm_learn_weights": false,
                "use_categorical": false,
                "categorical_dim": 10,
                "categorical_gumbel_softmax_hard": false,
                "categorical_init_temp": 1.0,
                "categorical_temp_anneal_step": 0.001,
                "categorical_min_temp": 0.3
            },
            "encoder_layer_dims": [
                300,
                400
            ],
            "decoder_layer_dims": [
                300,
                400
            ],
            "prior_layer_dims": [
                300,
                400
            ]
        },
        "rnn": {
            "enabled": false,
            "horizon": 10,
            "hidden_dim": 400,
            "rnn_type": "LSTM",
            "num_layers": 2,
            "open_loop": false,
            "kwargs": {
                "bidirectional": false
            }
        },
        "transformer": {
            "enabled": false,
            "context_length": 10,
            "embed_dim": 512,
            "num_layers": 6,
            "num_heads": 8,
            "emb_dropout": 0.1,
            "attn_dropout": 0.1,
            "block_output_dropout": 0.1,
            "sinusoidal_embedding": false,
            "activation": "gelu",
            "supervise_all_steps": false,
            "nn_parameter_for_timesteps": true
        }
    },
    "observation": {
        "modalities": {
            "obs": {
                "low_dim": [
                    "robot0_base_to_eef_pos",
                    "robot0_base_to_eef_quat",
                    "robot0_base_pos",
                    "robot0_base_quat",
                    "robot0_gripper_qpos"
                ],
                "rgb": [
                    "robot0_agentview_left_image",
                    "robot0_agentview_right_image",
                    "robot0_eye_in_hand_image"
                ],
                "depth": [],
                "scan": []
            },
            "goal": {
                "low_dim": [],
                "rgb": [],
                "depth": [],
                "scan": []
            }
        },
        "encoder": {
            "low_dim": {
                "core_class": null,
                "core_kwargs": {},
                "obs_randomizer_class": null,
                "obs_randomizer_kwargs": {}
            },
            "rgb": {
                "core_class": "VisualCoreLanguageConditioned",
                "core_kwargs": {
                    "backbone_class": "ResNet18ConvFiLM"
                },
                "obs_randomizer_class": null,
                "obs_randomizer_kwargs": {
                    "crop_height": 116,
                    "crop_width": 116,
                    "num_crops": 1,
                    "pos_enc": false
                }
            },
            "depth": {
                "core_class": "VisualCore",
                "core_kwargs": {},
                "obs_randomizer_class": null,
                "obs_randomizer_kwargs": {}
            },
            "scan": {
                "core_class": "ScanCore",
                "core_kwargs": {},
                "obs_randomizer_class": null,
                "obs_randomizer_kwargs": {}
            }
        }
    },
    "meta": {
        "hp_base_config_file": "/home/lucas/robocasa/robomimic/robomimic/exps/templates/bc.json",
        "hp_keys": [
            "seed",
            "ds",
            "obsrandargs"
        ],
        "hp_values": [
            123,
            "OpenSingleDoor",
            {
                "crop_height": 116,
                "crop_width": 116,
                "num_crops": 1,
                "pos_enc": false
            }
        ]
    }
}
luccachiang commented 3 months ago

Sorry, I've finally found the solution. I encountered this problem because I git clone robosuite in the folder of robocasa. As a result, the folder name robosuite has conflicts with the package name. After renaming the folder name, I solved this problem :)