facebookresearch / mtrl

Multi Task RL Baselines
MIT License
223 stars 28 forks source link

Raise ValueError: Empty module name when trying to run a demo #21

Open Zhennan-Wu opened 2 years ago

Zhennan-Wu commented 2 years ago

Description

I was trying to play with the code to run a demo, but I kept getting the error as in the title no matter which configuration I used from the documentation examples.

How to reproduce

I got the error by simply ran PYTHONPATH=. python main.py env=metaworld-ml1.

Stack trace / error message

https://gist.github.com/Zhennan-Wu/4e3640e5cce8e1c50d82dba790bf5a1f

System information

Any other information

Add any other information here.

shagunsodhani commented 2 years ago

Hi! Only metaworld-mt10 and metaworld-mt50 environments are supported. Let me know if that works for you.

Zhennan-Wu commented 2 years ago

Hi, I tried metaworld-mt10 but still got the same error: Traceback (most recent call last): File "/home/leo/miniconda3/envs/rlproject/lib/python3.8/site-packages/hydra/_internal/utils.py", line 529, in _locate module = import_module(mod) File "/home/leo/miniconda3/envs/rlproject/lib/python3.8/importlib/init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1011, in _gcd_import File "", line 950, in _sanity_check ValueError: Empty module name

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/home/leo/miniconda3/envs/rlproject/lib/python3.8/site-packages/hydra/utils.py", line 61, in call type_or_callable = _locate(cls) File "/home/leo/miniconda3/envs/rlproject/lib/python3.8/site-packages/hydra/_internal/utils.py", line 532, in _locate raise ImportError(f"Error loading module '{path}'") from e ImportError: Error loading module 'metaworld.MT10'

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/home/leo/miniconda3/envs/rlproject/lib/python3.8/site-packages/hydra/utils.py", line 63, in call return _instantiate_class(type_or_callable, config, *args, *kwargs) File "/home/leo/miniconda3/envs/rlproject/lib/python3.8/site-packages/hydra/_internal/utils.py", line 500, in _instantiate_class return clazz(args, **final_kwargs) File "/home/leo/Documents/GoogleDrive/SchoolWorkIU/CSCIB659RL/hws/final project/mtrl/mtrl/experiment/metaworld.py", line 20, in init super().init(config, experiment_id) File "/home/leo/Documents/GoogleDrive/SchoolWorkIU/CSCIB659RL/hws/final project/mtrl/mtrl/experiment/multitask.py", line 25, in init super().init(config, experiment_id) File "/home/leo/Documents/GoogleDrive/SchoolWorkIU/CSCIB659RL/hws/final project/mtrl/mtrl/experiment/experiment.py", line 33, in init self.envs, self.env_metadata = self.build_envs() File "/home/leo/Documents/GoogleDrive/SchoolWorkIU/CSCIB659RL/hws/final project/mtrl/mtrl/experiment/metaworld.py", line 43, in build_envs benchmark = hydra.utils.instantiate(self.config.env.benchmark) File "/home/leo/miniconda3/envs/rlproject/lib/python3.8/site-packages/hydra/utils.py", line 70, in call raise HydraException(f"Error calling '{cls}' : {e}") from e hydra.errors.HydraException: Error calling 'metaworld.MT10' : Error loading module 'metaworld.MT10'

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "main.py", line 15, in launch return run(config) File "/home/leo/Documents/GoogleDrive/SchoolWorkIU/CSCIB659RL/hws/final project/mtrl/mtrl/app/run.py", line 35, in run experiment_utils.prepare_and_run(config=config) File "/home/leo/Documents/GoogleDrive/SchoolWorkIU/CSCIB659RL/hws/final project/mtrl/mtrl/experiment/utils.py", line 23, in prepare_and_run experiment = hydra.utils.instantiate( File "/home/leo/miniconda3/envs/rlproject/lib/python3.8/site-packages/hydra/utils.py", line 70, in call raise HydraException(f"Error calling '{cls}' : {e}") from e hydra.errors.HydraException: Error calling 'mtrl.experiment.metaworld.Experiment' : Error calling 'metaworld.MT10' : Error loading module 'metaworld.MT10'

Set the environment variable HYDRA_FULL_ERROR=1 for a complete stack trace.

shagunsodhani commented 2 years ago

Could you please share the metaworld version (git commit) that you are using.

Zhennan-Wu commented 2 years ago

Hi, the commit version is the following,

commit e282c3f5a205970b4ad7d1c1ebae7aa9b4d56218 (HEAD -> main, origin/main, origin/HEAD) Merge: 0b991a1 96a92ae Author: Shagun Sodhani 1321193+shagunsodhani@users.noreply.github.com Date: Thu Dec 30 22:40:39 2021 -0500

Merge pull request #12 from facebookresearch/shagunsodhani-typing-extension

Relax the version for typing extensions
Zhennan-Wu commented 2 years ago

I also check the git log, but did not find the commit af8417bfc82a3e249b4b02156518d775f29eb289 in the document for

The full git log:

commit e282c3f5a205970b4ad7d1c1ebae7aa9b4d56218 (HEAD -> main, origin/main, origin/HEAD) Merge: 0b991a1 96a92ae Author: Shagun Sodhani 1321193+shagunsodhani@users.noreply.github.com Date: Thu Dec 30 22:40:39 2021 -0500

Merge pull request #12 from facebookresearch/shagunsodhani-typing-extension

Relax the version for typing extensions

commit 96a92ae3d5da7c0276d5e2a689ca7dc1840bab19 (origin/shagunsodhani-typing-extension) Author: Shagun Sodhani 1321193+shagunsodhani@users.noreply.github.com Date: Thu Dec 30 18:57:26 2021 -0500

Relax the version for typing extensions

commit 0b991a1bdfa7894f8807011616c5f0aeb7cc2407 Author: Shagun Sodhani 1321193+shagunsodhani@users.noreply.github.com Date: Thu Dec 30 18:27:53 2021 -0500

Add metaworld commit info

commit 184c7d39db21acc505cf7094ed87cd28a1735105 Merge: 6b92683 ad63167 Author: Shagun Sodhani 1321193+shagunsodhani@users.noreply.github.com Date: Tue Jun 29 06:46:37 2021 -0400

Merge pull request #7 from facebookresearch/fix-6

Remove dependency on `metaworld`

commit ad63167184643d53385d38801c2ae854f2da067c (origin/fix-6) Author: Shagun Sodhani 1321193+shagunsodhani@users.noreply.github.com Date: Sat Jun 26 13:27:53 2021 -0400

Remove dependency on `metaworld`

Fixes #6

commit 6b9268316c958d2f79755e976ecfeb0400153e1d Author: Shagun Sodhani sodhani@fb.com Date: Sat May 29 18:29:12 2021 -0700

Add CARE paper

commit 20ee73459f46fd64809014a7baf7789511dcc3be Merge: eea3c99 36a2e2a Author: Shagun Sodhani 1321193+shagunsodhani@users.noreply.github.com Date: Wed Apr 21 21:47:15 2021 -0400

Merge pull request #5 from facebookresearch/iss4

Fix typos related to HiP-BMDP

commit 36a2e2a354eae673d61ea3276166e2072811dc78 (origin/iss4) Author: Shagun Sodhani sodhani@fb.com Date: Wed Apr 21 18:01:23 2021 -0700

Update command for running HiP-BMDP model. Related to #4

commit d8c37b1eb144cb315b2de04e0ab1c3c678bb8f10 Author: Shagun Sodhani sodhani@fb.com Date: Wed Apr 21 17:58:23 2021 -0700

Fix a typo. Related to #4

commit eea3c99cc116e0fadc41815d0e7823349fcc0bf4 Merge: dbab5f8 cad7073 Author: Shagun Sodhani 1321193+shagunsodhani@users.noreply.github.com Date: Sat Mar 20 10:26:44 2021 -0400

Merge pull request #2 from facebookresearch/fix-iss-1

Add missing configs.

commit cad70732c6ee5e17ff8dbcd151efc0495224b1be Author: Shagun Sodhani sodhani@fb.com Date: Sat Mar 6 10:55:21 2021 -0800

Delete mongo config

commit ce04025bb1d26672ed50e7b89d9adc74a7fcc471 Author: Shagun Sodhani sodhani@fb.com Date: Fri Mar 5 19:48:38 2021 -0800

Add missing configs.

commit dbab5f82297c88ea14cf46f2036c9d8e0c48d249 Author: Shagun Sodhani sodhani@fb.com Date: Sun Feb 28 06:22:21 2021 -0800

Update hipbmdp config. It was missing the task encoder.

commit b6db5d8c1a273cc38ffd8613a70ad54426806dae Author: Shagun Sodhani sodhani@fb.com Date: Fri Feb 26 12:42:22 2021 -0800

Add acknowledgment for SAC code.

commit f7f8ddcf01e24a449b2fb368589d8bb1d94cca1e Author: Shagun Sodhani 1321193+shagunsodhani@users.noreply.github.com Date: Fri Feb 26 13:53:10 2021 -0500

Add acknowledgment for SAC code.

commit e6c0e4a93d40ef3267ddba873da0afe9571eab45 Author: Shagun Sodhani sodhani@fb.com Date: Thu Feb 11 18:40:43 2021 -0800

Initial commit
shagunsodhani commented 2 years ago

I was asking for the git commit for metaworld and not mtrl :)

Zhennan-Wu commented 2 years ago

Hi Shagun,

Thank you for the timely response. But I am confused. I only cloned this repository and ran the requirements installation. Then I tried to run the demo but got the error. So I did not manually installed metaworld myself.

The question suggests that I need to install metaworld myself and I just tried pip install git+https://github.com/facebookresearch/mtenv.git@main#egg="mtenv[metaworld]" to install metaworld environment. But that does not solve the problem. The version information is

Name: metaworld Version: 0.1.0 Summary: UNKNOWN Home-page: UNKNOWN Author: Author-email: License: UNKNOWN Location: /home/leo/miniconda3/envs/mtrl/lib/python3.8/site-packages Requires: numpy, gym, mujoco-py Required-by:

How should I proceed?

Thanks!

shagunsodhani commented 2 years ago

Well the problem is, metaworld is a fast moving codebase so we developed/tested our setup against a specific commit of metaworld: af8417bfc82a3e249b4b02156518d775f29eb289. Could you please try to install metaworld from this commit and check

Zhennan-Wu commented 2 years ago

Hi Shagun,

I tried to installed the metaworld af8417bfc82a3e249b4b02156518d775f29eb289 as shown in the git show

commit af8417bfc82a3e249b4b02156518d775f29eb289 (HEAD) Author: Adithya Bellathur bellathu@usc.edu Date: Wed Aug 26 12:56:11 2020 -0700

Then I reinstalled the mtrl package. But when I ran the demo script it still shows the same error

Starting Experiment at Wed Apr 13 15:15:12 2022 torch version = 1.7.1+cu110 Traceback (most recent call last): File "/home/leo/miniconda3/envs/mtrl/lib/python3.8/site-packages/hydra/_internal/utils.py", line 529, in _locate module = import_module(mod) File "/home/leo/miniconda3/envs/mtrl/lib/python3.8/importlib/init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1011, in _gcd_import File "", line 950, in _sanity_check ValueError: Empty module name

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/home/leo/miniconda3/envs/mtrl/lib/python3.8/site-packages/hydra/utils.py", line 61, in call type_or_callable = _locate(cls) File "/home/leo/miniconda3/envs/mtrl/lib/python3.8/site-packages/hydra/_internal/utils.py", line 532, in _locate raise ImportError(f"Error loading module '{path}'") from e ImportError: Error loading module 'metaworld.MT10'

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/home/leo/miniconda3/envs/mtrl/lib/python3.8/site-packages/hydra/utils.py", line 63, in call return _instantiate_class(type_or_callable, config, *args, *kwargs) File "/home/leo/miniconda3/envs/mtrl/lib/python3.8/site-packages/hydra/_internal/utils.py", line 500, in _instantiate_class return clazz(args, **final_kwargs) File "/home/leo/Documents/GoogleDrive/SchoolWorkIU/CSCIB659RL/hws/final project/mtrl/mtrl/experiment/metaworld.py", line 20, in init super().init(config, experiment_id) File "/home/leo/Documents/GoogleDrive/SchoolWorkIU/CSCIB659RL/hws/final project/mtrl/mtrl/experiment/multitask.py", line 25, in init super().init(config, experiment_id) File "/home/leo/Documents/GoogleDrive/SchoolWorkIU/CSCIB659RL/hws/final project/mtrl/mtrl/experiment/experiment.py", line 33, in init self.envs, self.env_metadata = self.build_envs() File "/home/leo/Documents/GoogleDrive/SchoolWorkIU/CSCIB659RL/hws/final project/mtrl/mtrl/experiment/metaworld.py", line 43, in build_envs benchmark = hydra.utils.instantiate(self.config.env.benchmark) File "/home/leo/miniconda3/envs/mtrl/lib/python3.8/site-packages/hydra/utils.py", line 70, in call raise HydraException(f"Error calling '{cls}' : {e}") from e hydra.errors.HydraException: Error calling 'metaworld.MT10' : Error loading module 'metaworld.MT10'

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/home/leo/miniconda3/envs/mtrl/lib/python3.8/site-packages/hydra/_internal/utils.py", line 198, in run_and_report return func() File "/home/leo/miniconda3/envs/mtrl/lib/python3.8/site-packages/hydra/_internal/utils.py", line 347, in lambda: hydra.run( File "/home/leo/miniconda3/envs/mtrl/lib/python3.8/site-packages/hydra/_internal/hydra.py", line 107, in run return run_job( File "/home/leo/miniconda3/envs/mtrl/lib/python3.8/site-packages/hydra/core/utils.py", line 128, in run_job ret.return_value = task_function(task_cfg) File "main.py", line 15, in launch return run(config) File "/home/leo/Documents/GoogleDrive/SchoolWorkIU/CSCIB659RL/hws/final project/mtrl/mtrl/app/run.py", line 35, in run experiment_utils.prepare_and_run(config=config) File "/home/leo/Documents/GoogleDrive/SchoolWorkIU/CSCIB659RL/hws/final project/mtrl/mtrl/experiment/utils.py", line 23, in prepare_and_run experiment = hydra.utils.instantiate( File "/home/leo/miniconda3/envs/mtrl/lib/python3.8/site-packages/hydra/utils.py", line 70, in call raise HydraException(f"Error calling '{cls}' : {e}") from e hydra.errors.HydraException: Error calling 'mtrl.experiment.metaworld.Experiment' : Error calling 'metaworld.MT10' : Error loading module 'metaworld.MT10'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "main.py", line 19, in launch() File "/home/leo/miniconda3/envs/mtrl/lib/python3.8/site-packages/hydra/main.py", line 32, in decorated_main _run_hydra( File "/home/leo/miniconda3/envs/mtrl/lib/python3.8/site-packages/hydra/_internal/utils.py", line 346, in _run_hydra run_and_report( File "/home/leo/miniconda3/envs/mtrl/lib/python3.8/site-packages/hydra/_internal/utils.py", line 237, in run_and_report assert mdl is not None AssertionError

shagunsodhani commented 2 years ago

It still seems like an issue with importing metaworld. Could you try running the following in a standalone python shell

import metaworld
import random

ml10 = metaworld.ML10() # Construct the benchmark, sampling tasks

training_envs = []
for name, env_cls in ml10.train_classes.items():
  env = env_cls()
  task = random.choice([task for task in ml10.train_tasks
                        if task.env_name == name])
  env.set_task(task)
  training_envs.append(env)

for env in training_envs:
  obs = env.reset()  # Reset environment
  a = env.action_space.sample()  # Sample an action
  obs, reward, done, info = env.step(a)  # Step the environoment with the sampled random action
Zhennan-Wu commented 2 years ago

Actually, it reported error when I tried to import metaworld:

File "mujoco_py/cymj.pyx", line 1, in init mujoco_py.cymj ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 96 from C header, got 80 from PyObject

I ran into the same error when I tried the latest metaworld myself, but over there I solved it by not using pip cache when installing. I tried the same with reinstalling mtrl but it remains the same.

Zhennan-Wu commented 2 years ago

Hi Shagun,

I tried the whole procedure again and here is some update.

I first installed mujoco200 not using cache (required for the metaworld commit version) and tested it. It worked normally. Then I installed the specific commit of metaworld not using cache and try to import it, everything worked fine. Finally I installed mtrl not using cache and tried to import metaworld again, and it showed the error.

Any suggestions?

shagunsodhani commented 2 years ago

Try installing metaworld after installing mtrl. When u install mtrl, it likely re-installs a new version of metaworld

Zhennan-Wu commented 2 years ago

That sounds reasonable, but I tried it and it did not work.

Zhennan-Wu commented 2 years ago

Hi Shagun,

I solved the issue by upgrade numpy to the latest version. Then I ran the demo code you provided in a standalone python shell and everything worked normally. But when I ran the demo code in the documentation, I occurred another error:

Traceback (most recent call last): File "/home/leo/miniconda3/envs/mtrl/lib/python3.8/site-packages/hydra/utils.py", line 63, in call return _instantiate_class(type_or_callable, config, *args, *kwargs) File "/home/leo/miniconda3/envs/mtrl/lib/python3.8/site-packages/hydra/_internal/utils.py", line 500, in _instantiate_class return clazz(args, final_kwargs) File "/home/leo/Documents/GoogleDrive/SchoolWorkIU/CSCIB659RL/hws/final project/mtrl/mtrl/experiment/metaworld.py", line 20, in init super().init(config, experiment_id) File "/home/leo/Documents/GoogleDrive/SchoolWorkIU/CSCIB659RL/hws/final project/mtrl/mtrl/experiment/multitask.py", line 25, in init super().init(config, experiment_id) File "/home/leo/Documents/GoogleDrive/SchoolWorkIU/CSCIB659RL/hws/final project/mtrl/mtrl/experiment/experiment.py", line 33, in init self.envs, self.env_metadata = self.build_envs() File "/home/leo/Documents/GoogleDrive/SchoolWorkIU/CSCIB659RL/hws/final project/mtrl/mtrl/experiment/metaworld.py", line 47, in build_envs envs[mode], env_id_to_task_map = env_builder.build_metaworld_vec_env( File "/home/leo/Documents/GoogleDrive/SchoolWorkIU/CSCIB659RL/hws/final project/mtrl/mtrl/env/builder.py", line 51, in build_metaworld_vec_env from mtenv.envs.metaworld.env import ( File "/home/leo/Documents/GoogleDrive/SchoolWorkIU/CSCIB659RL/hws/final project/mtrl/src/mtenv/mtenv/envs/init.py", line 10, in register( File "/home/leo/Documents/GoogleDrive/SchoolWorkIU/CSCIB659RL/hws/final project/mtrl/src/mtenv/mtenv/envs/registration.py", line 74, in register return mtenv_registry.register(id, kwargs) File "/home/leo/Documents/GoogleDrive/SchoolWorkIU/CSCIB659RL/hws/final project/mtrl/src/mtenv/mtenv/envs/registration.py", line 66, in register self.env_specs[id] = MultitaskEnvSpec(id, **kwargs) File "/home/leo/Documents/GoogleDrive/SchoolWorkIU/CSCIB659RL/hws/final project/mtrl/src/mtenv/mtenv/envs/registration.py", line 41, in init super().init( TypeError: init() got an unexpected keyword argument 'id'

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/home/leo/miniconda3/envs/mtrl/lib/python3.8/site-packages/hydra/_internal/utils.py", line 198, in run_and_report return func() File "/home/leo/miniconda3/envs/mtrl/lib/python3.8/site-packages/hydra/_internal/utils.py", line 347, in lambda: hydra.run( File "/home/leo/miniconda3/envs/mtrl/lib/python3.8/site-packages/hydra/_internal/hydra.py", line 107, in run return run_job( File "/home/leo/miniconda3/envs/mtrl/lib/python3.8/site-packages/hydra/core/utils.py", line 128, in run_job ret.return_value = task_function(task_cfg) File "main.py", line 15, in launch return run(config) File "/home/leo/Documents/GoogleDrive/SchoolWorkIU/CSCIB659RL/hws/final project/mtrl/mtrl/app/run.py", line 35, in run experiment_utils.prepare_and_run(config=config) File "/home/leo/Documents/GoogleDrive/SchoolWorkIU/CSCIB659RL/hws/final project/mtrl/mtrl/experiment/utils.py", line 23, in prepare_and_run experiment = hydra.utils.instantiate( File "/home/leo/miniconda3/envs/mtrl/lib/python3.8/site-packages/hydra/utils.py", line 70, in call raise HydraException(f"Error calling '{cls}' : {e}") from e hydra.errors.HydraException: Error calling 'mtrl.experiment.metaworld.Experiment' : init() got an unexpected keyword argument 'id'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "main.py", line 19, in launch() File "/home/leo/miniconda3/envs/mtrl/lib/python3.8/site-packages/hydra/main.py", line 32, in decorated_main _run_hydra( File "/home/leo/miniconda3/envs/mtrl/lib/python3.8/site-packages/hydra/_internal/utils.py", line 346, in _run_hydra run_and_report( File "/home/leo/miniconda3/envs/mtrl/lib/python3.8/site-packages/hydra/_internal/utils.py", line 237, in run_and_report assert mdl is not None

Any advice? Thanks!

heshandevaka commented 2 years ago

Hi, I had the same issue with running the demo code for MT10, and resolved it by switching from python 3.7 to python 3.6.8. If you are trying this fix, you might also need to change the pandas version in requirements/dev.txt from pandas==1.2.0 to pandas==1.1.5.