Git Product home page Git Product logo

Comments (7)

ellemcfarlane avatar ellemcfarlane commented on July 19, 2024

Okay, I have a potential M2 setup but hard to tell if it's valid since I ran into other issues when running scripts.

This is what I did, where pycond is aliased to /Users/ellemcfarlane/miniconda/envs/vcond/bin/python3 and python version is 3.9.16:

  1. followed advice here for cpprb keiohta/tf2rl#75 although not sure it was needed in the end since I fixed my numpy issues with cpprb/pandas via step 2
  2. conda install 'numpy<1.20' (does not work with pip) since cpprb error was due to numpy>=1.20
  3. pycond -m pip install --no-binary cpprb "cpprb==10.2.0" && remove this from requirements.txt
  4. replace torch version in requirements.txt to torch==1.9.* (1.8 not available for my setup)
  5. pycond -m pip install -r requirements.txt
  6. pycond -m pip install -e .
  7. pycond -m pip install -U lbforaging rware

Note: some other dependency appears to ultimately change the numpy version to 1.24.3

I also:

  1. pycond -m pip install gym==0.22, otherwise this error appears:
AttributeError: module 'gym.wrappers' has no attribute 'Monitor'
  1. pycond -m pip install click which is needed by search.py

Then, I run into runtime issues:
1.

pycond run.py +algorithm=ac env.name="lbforaging:Foraging-8x8-2p-3f-v2" env.time_limit=25

Error executing job with overrides: ['+algorithm=ac', 'env.name=lbforaging:Foraging-8x8-2p-3f-v2', 'env.time_limit=25']
Traceback (most recent call last):
  File "/Users/ellemcfarlane/miniconda/envs/vcond/lib/python3.9/site-packages/hydra/_internal/instantiate/_instantiate2.py", line 62, in _call_target
    return _target_(*args, **kwargs)
  File "/Users/ellemcfarlane/Documents/codigo/fast-marl/fastmarl/utils/envs.py", line 83, in make_env
    return _make_parallel_envs(**env, seed=seed)
  File "/Users/ellemcfarlane/Documents/codigo/fast-marl/fastmarl/utils/envs.py", line 56, in _make_parallel_envs
    envs = DummyVecEnv(env_thunks)
  File "/Users/ellemcfarlane/miniconda/envs/vcond/lib/python3.9/site-packages/stable_baselines3/common/vec_env/dummy_vec_env.py", line 25, in __init__
    self.envs = [fn() for fn in env_fns]
  File "/Users/ellemcfarlane/miniconda/envs/vcond/lib/python3.9/site-packages/stable_baselines3/common/vec_env/dummy_vec_env.py", line 25, in <listcomp>
    self.envs = [fn() for fn in env_fns]
  File "/Users/ellemcfarlane/Documents/codigo/fast-marl/fastmarl/utils/envs.py", line 39, in _env_thunk
    env = gym.make(name, **kwargs)
  File "/Users/ellemcfarlane/miniconda/envs/vcond/lib/python3.9/site-packages/gym/envs/registration.py", line 676, in make
    return registry.make(id, **kwargs)
  File "/Users/ellemcfarlane/miniconda/envs/vcond/lib/python3.9/site-packages/gym/envs/registration.py", line 490, in make
    versions = self.env_specs.versions(namespace, name)
  File "/Users/ellemcfarlane/miniconda/envs/vcond/lib/python3.9/site-packages/gym/envs/registration.py", line 220, in versions
    self._assert_name_exists(namespace, name)
  File "/Users/ellemcfarlane/miniconda/envs/vcond/lib/python3.9/site-packages/gym/envs/registration.py", line 297, in _assert_name_exists
    raise error.NameNotFound(message)
gym.error.NameNotFound: Environment `lbforaging:Foraging-8x8-2p-3f` doesn't exist.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/ellemcfarlane/Documents/codigo/fast-marl/fastmarl/run.py", line 18, in main
    env = hydra.utils.call(cfg.env, cfg.seed)
  File "/Users/ellemcfarlane/miniconda/envs/vcond/lib/python3.9/site-packages/hydra/_internal/instantiate/_instantiate2.py", line 180, in instantiate
    return instantiate_node(config, *args, recursive=_recursive_, convert=_convert_)
  File "/Users/ellemcfarlane/miniconda/envs/vcond/lib/python3.9/site-packages/hydra/_internal/instantiate/_instantiate2.py", line 249, in instantiate_node
    return _call_target(_target_, *args, **kwargs)
  File "/Users/ellemcfarlane/miniconda/envs/vcond/lib/python3.9/site-packages/hydra/_internal/instantiate/_instantiate2.py", line 64, in _call_target
    raise type(e)(
  File "/Users/ellemcfarlane/miniconda/envs/vcond/lib/python3.9/site-packages/hydra/_internal/instantiate/_instantiate2.py", line 62, in _call_target
    return _target_(*args, **kwargs)
  File "/Users/ellemcfarlane/Documents/codigo/fast-marl/fastmarl/utils/envs.py", line 83, in make_env
    return _make_parallel_envs(**env, seed=seed)
  File "/Users/ellemcfarlane/Documents/codigo/fast-marl/fastmarl/utils/envs.py", line 56, in _make_parallel_envs
    envs = DummyVecEnv(env_thunks)
  File "/Users/ellemcfarlane/miniconda/envs/vcond/lib/python3.9/site-packages/stable_baselines3/common/vec_env/dummy_vec_env.py", line 25, in __init__
    self.envs = [fn() for fn in env_fns]
  File "/Users/ellemcfarlane/miniconda/envs/vcond/lib/python3.9/site-packages/stable_baselines3/common/vec_env/dummy_vec_env.py", line 25, in <listcomp>
    self.envs = [fn() for fn in env_fns]
  File "/Users/ellemcfarlane/Documents/codigo/fast-marl/fastmarl/utils/envs.py", line 39, in _env_thunk
    env = gym.make(name, **kwargs)
  File "/Users/ellemcfarlane/miniconda/envs/vcond/lib/python3.9/site-packages/gym/envs/registration.py", line 676, in make
    return registry.make(id, **kwargs)
  File "/Users/ellemcfarlane/miniconda/envs/vcond/lib/python3.9/site-packages/gym/envs/registration.py", line 490, in make
    versions = self.env_specs.versions(namespace, name)
  File "/Users/ellemcfarlane/miniconda/envs/vcond/lib/python3.9/site-packages/gym/envs/registration.py", line 220, in versions
    self._assert_name_exists(namespace, name)
  File "/Users/ellemcfarlane/miniconda/envs/vcond/lib/python3.9/site-packages/gym/envs/registration.py", line 297, in _assert_name_exists
    raise error.NameNotFound(message)
gym.error.NameNotFound: Error instantiating 'utils.envs.make_env' : Environment `lbforaging:Foraging-8x8-2p-3f` doesn't exist.

this looks like maybe somewhere import lbforaging should be executed but isn't? I tried importing directly into run.py but the import seems to hang forever.

pycond search.py run --config configs/algorithm/dqn.yaml --seeds 5 locally               
There are 5 combinations of configurations. Up to 7 will run in parallel. Continue? [y/N]: y
python: can't open file 'main.py': [Errno 2] No such file or directory
python: can't open file 'main.py': [Errno 2] No such file or directory
python: can't open file 'main.py': [Errno 2] No such file or directory
python: can't open file 'main.py': [Errno 2] No such file or directory
python: can't open file 'main.py': [Errno 2] No such file or directory
[2, 2, 2, 2, 2]

perhaps here main.py is being hardcoded via configs = ["python main.py " + "-m " + " ".join([c for c in combo]) for combo in combos] when it should be reading something from the config? Also, the readme says to use configs/sweeps/dqn.lbf.yaml which is not in this repo, hence why I used configs/algorithm/dqn.yaml instead.

Would appreciate any tips for these issues 🙂

from codebase.

semitable avatar semitable commented on July 19, 2024

Hi,

Regarding the PyTorch issue, I think it's best to install it from PyTorch's website. It depends on the info (my Linux system didn't run into any issues, but I can see how it might be different for macOS/Windows/different GPUs, etc).

We might as well remove it from the requirements file and ask people to install it from: https://pytorch.org/get-started/locally/

Unfortunately, the other issues you are encountering are because of the gym==0.22 version. Both LBF and RWARE need 0.21 at the moment: With that version, lbforaging (or any other dependency) will load automatically when the environment name starts with it, e.g. "lbforaging:ENV-NAME" is identical to import lbforaging.
Also, in 0.22 LBF hangs because gym has added a weird fuzzy search mechanism for the names.

We are aware of both issues and looking into updating them. However, there is an issue deep within RWARE that doesn't make that easy.

Can you give me more info on the
AttributeError: module 'gym.wrappers' has no attribute 'Monitor'
problem? When does it appear? Is there a stacktrace?

from codebase.

ellemcfarlane avatar ellemcfarlane commented on July 19, 2024

Thanks for the quick response!

Yeah, may make sense to ask people to install it manually. For now, I'll stick with my torch version unless I see it's breaking things.

I tried installing gym 0.21 (and 0.20 as a sanity test), but run into this issue I've been trying to resolve:

pycond -m pip install "gym==0.21"
Collecting gym==0.21
  Using cached gym-0.21.0.tar.gz (1.5 MB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [1 lines of output]
      error in gym setup command: 'extras_require' must be a dictionary whose values are strings or lists of strings containing valid project/version requirement specifiers.
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

Have you seen this?

The Monitor bug happens in gym >= .23 (which was the default version installed with SB3 for me) due to this: https://github.com/openai/gym/releases/tag/0.23.0 that's why I downgraded to .22.

from codebase.

ellemcfarlane avatar ellemcfarlane commented on July 19, 2024

By the way, any input on the second issues I described with search.py?

from codebase.

semitable avatar semitable commented on July 19, 2024

I am not using pycond and can't reproduce the installation issue for gym (pip install gym==0.21) works fine in my system.
To be clear I just executed:
conda create -n test python=3.8 (to create an empty environment)
conda activate test
pip install gym==0.21 (to install gym with no errors)

Re search.py issue: I pushed a fix just now. It was trying to call "main.py" instead of "run.py" which was the old name.

from codebase.

ellemcfarlane avatar ellemcfarlane commented on July 19, 2024

Great! Thanks for pushing a fix. I had to replace the python in the command to the path for my conda python bin since despite aliasing it to "python" the code run by click doesn't seem to use it so I get import issues. Also, had to change yaml.load to yaml.safe_load otherwise get this error:

File "/Users/ellemcfarlane/Documents/codigo/fast-marl/fastmarl/search.py", line 39, in _load_config
    config = yaml.load(filename)
TypeError: load() missing 1 required positional argument: 'Loader'

After that, when running, I still see another error:

HYDRA_FULL_ERROR=1 python search.py run --config configs/algorithm/dqn.yaml --seeds 5 locally
There are 5 combinations of configurations. Up to 7 will run in parallel. Continue? [y/N]: y
Traceback (most recent call last):
  File "/Users/ellemcfarlane/Documents/codigo/fast-marl/fastmarl/run.py", line 33, in <module>
    main()
  File "/Users/ellemcfarlane/miniconda/envs/marl/lib/python3.9/site-packages/hydra/main.py", line 48, in decorated_main
    _run_hydra(
  File "/Users/ellemcfarlane/miniconda/envs/marl/lib/python3.9/site-packages/hydra/_internal/utils.py", line 385, in _run_hydra
    run_and_report(
  File "/Users/ellemcfarlane/miniconda/envs/marl/lib/python3.9/site-packages/hydra/_internal/utils.py", line 214, in run_and_report
    raise ex
  File "/Users/ellemcfarlane/miniconda/envs/marl/lib/python3.9/site-packages/hydra/_internal/utils.py", line 211, in run_and_report
    return func()
  File "/Users/ellemcfarlane/miniconda/envs/marl/lib/python3.9/site-packages/hydra/_internal/utils.py", line 386, in <lambda>
    lambda: hydra.multirun(
  File "/Users/ellemcfarlane/miniconda/envs/marl/lib/python3.9/site-packages/hydra/_internal/hydra.py", line 122, in multirun
    cfg = self.compose_config(
  File "/Users/ellemcfarlane/miniconda/envs/marl/lib/python3.9/site-packages/hydra/_internal/hydra.py", line 559, in compose_config
    cfg = self.config_loader.load_configuration(
  File "/Users/ellemcfarlane/miniconda/envs/marl/lib/python3.9/site-packages/hydra/_internal/config_loader_impl.py", line 141, in load_configuration
    return self._load_configuration_impl(
  File "/Users/ellemcfarlane/miniconda/envs/marl/lib/python3.9/site-packages/hydra/_internal/config_loader_impl.py", line 231, in _load_configuration_impl
    parsed_overrides = parser.parse_overrides(overrides=overrides)
  File "/Users/ellemcfarlane/miniconda/envs/marl/lib/python3.9/site-packages/hydra/core/override_parser/overrides_parser.py", line 96, in parse_overrides
    raise OverrideParseException(
hydra.errors.OverrideParseException: no viable alternative at input '{'_target_''
See https://hydra.cc/docs/next/advanced/override_grammar/basic for details
Traceback (most recent call last):
  File "/Users/ellemcfarlane/Documents/codigo/fast-marl/fastmarl/run.py", line 33, in <module>
    main()
  File "/Users/ellemcfarlane/miniconda/envs/marl/lib/python3.9/site-packages/hydra/main.py", line 48, in decorated_main
    _run_hydra(
  File "/Users/ellemcfarlane/miniconda/envs/marl/lib/python3.9/site-packages/hydra/_internal/utils.py", line 385, in _run_hydra
    run_and_report(
  File "/Users/ellemcfarlane/miniconda/envs/marl/lib/python3.9/site-packages/hydra/_internal/utils.py", line 214, in run_and_report
    raise ex
  File "/Users/ellemcfarlane/miniconda/envs/marl/lib/python3.9/site-packages/hydra/_internal/utils.py", line 211, in run_and_report
    return func()
  File "/Users/ellemcfarlane/miniconda/envs/marl/lib/python3.9/site-packages/hydra/_internal/utils.py", line 386, in <lambda>
    lambda: hydra.multirun(
  File "/Users/ellemcfarlane/miniconda/envs/marl/lib/python3.9/site-packages/hydra/_internal/hydra.py", line 122, in multirun
    cfg = self.compose_config(
  File "/Users/ellemcfarlane/miniconda/envs/marl/lib/python3.9/site-packages/hydra/_internal/hydra.py", line 559, in compose_config
    cfg = self.config_loader.load_configuration(
  File "/Users/ellemcfarlane/miniconda/envs/marl/lib/python3.9/site-packages/hydra/_internal/config_loader_impl.py", line 141, in load_configuration
    return self._load_configuration_impl(
  File "/Users/ellemcfarlane/miniconda/envs/marl/lib/python3.9/site-packages/hydra/_internal/config_loader_impl.py", line 231, in _load_configuration_impl
    parsed_overrides = parser.parse_overrides(overrides=overrides)
  File "/Users/ellemcfarlane/miniconda/envs/marl/lib/python3.9/site-packages/hydra/core/override_parser/overrides_parser.py", line 96, in parse_overrides
    raise OverrideParseException(
hydra.errors.OverrideParseException: no viable alternative at input '{'_target_''
See https://hydra.cc/docs/next/advanced/override_grammar/basic for details

Re gym issue: yeah, sorry, pycond is just an alias to my cond python binary. It still failed for me with a clean environment, so I decided to install gym 21 with conda (which was also the fix for my numpy issue) and ran into a architecture issue. Then, I restarted from scratch, installed gym first, repeated the steps I mentioned above and now everything appears to work :)

(marl) [email protected] /Users/ellemcfarlane/Documents/codigo/fast-marl/fastmarl [elle]
% /Users/ellemcfarlane/miniconda/envs/marl/bin/python run.py +algorithm=ac env.name="lbforaging:Foraging-8x8-2p-3f-v2" env.time_limit=25
/Users/ellemcfarlane/miniconda/envs/marl/lib/python3.9/site-packages/gym/spaces/box.py:73: UserWarning: WARN: Box bound precision lowered by casting to float32
  logger.warn(
(78306) [WARNING] - (06/11 13:03:44) - root >> No seed has been set.
Policy(
  (actor): MultiAgentFCNetwork(
    (independent): ModuleList(
      (0): Sequential(
        (0): Linear(in_features=15, out_features=64, bias=True)
        (1): ReLU()
        (2): Linear(in_features=64, out_features=64, bias=True)
        (3): ReLU()
        (4): Linear(in_features=64, out_features=6, bias=True)
      )
      (1): Sequential(
        (0): Linear(in_features=15, out_features=64, bias=True)
        (1): ReLU()
        (2): Linear(in_features=64, out_features=64, bias=True)
        (3): ReLU()
        (4): Linear(in_features=64, out_features=6, bias=True)
      )
    )
  )
  (critic): MultiAgentFCNetwork(
    (independent): ModuleList(
      (0): Sequential(
        (0): Linear(in_features=15, out_features=64, bias=True)
        (1): ReLU()
        (2): Linear(in_features=64, out_features=64, bias=True)
        (3): ReLU()
        (4): Linear(in_features=64, out_features=1, bias=True)
      )
      (1): Sequential(
        (0): Linear(in_features=15, out_features=64, bias=True)
        (1): ReLU()
        (2): Linear(in_features=64, out_features=64, bias=True)
        (3): ReLU()
        (4): Linear(in_features=64, out_features=1, bias=True)
      )
    )
  )
  (target_critic): MultiAgentFCNetwork(
    (independent): ModuleList(
      (0): Sequential(
        (0): Linear(in_features=15, out_features=64, bias=True)
        (1): ReLU()
        (2): Linear(in_features=64, out_features=64, bias=True)
        (3): ReLU()
        (4): Linear(in_features=64, out_features=1, bias=True)
      )
      (1): Sequential(
        (0): Linear(in_features=15, out_features=64, bias=True)
        (1): ReLU()
        (2): Linear(in_features=64, out_features=64, bias=True)
        (3): ReLU()
        (4): Linear(in_features=64, out_features=1, bias=True)
      )
    )
  )
)
(78306) [INFO] - (06/11 13:03:44) - root >> Updates 1, Environment timesteps 80
(78306) [INFO] - (06/11 13:03:44) - root >> Completed: 0.00%
(78306) [INFO] - (06/11 13:03:44) - root >> Last 3 episodes with mean returns: 0.000
(78306) [INFO] - (06/11 13:03:44) - root >> -------------------------------------------
(78306) [INFO] - (06/11 13:05:07) - root >> Updates 10000, Environment timesteps 800000
(78306) [INFO] - (06/11 13:05:07) - root >> UPS: 120.03, FPS: 9602.71 (wall time)
(78306) [INFO] - (06/11 13:05:07) - root >> UPS: 120.24, FPS: 9618.86 (cpu time)
(78306) [INFO] - (06/11 13:05:07) - root >> Elapsed Time: 0:01:25
(78306) [INFO] - (06/11 13:05:07) - root >> Estim. Time Left: 0:12:45
(78306) [INFO] - (06/11 13:05:07) - root >> Completed: 10.00%
(78306) [INFO] - (06/11 13:05:07) - root >> Last 20 episodes with mean returns: 0.733
(78306) [INFO] - (06/11 13:05:07) - root >> -------------------------------------------

from codebase.

ellemcfarlane avatar ellemcfarlane commented on July 19, 2024

For what it's worth, I ran into the gym 21 installation issue again, this time on linux & python 3.8. The issue is apparently caused by openai/gym#3176. The suggested solution for me didn't work for python 3.8 venv but did work for a python 3.9 conda env:

$ conda -n create venv39 python=3.9
$ python3 -m pip install setuptools==65.5.0
$ python3 -m pip install gym==0.21.0
$ python3 -m pip install -r requirements.txt
$ pip install -e .
$ python3 -m pip install -U lbforaging rware
$ cd fastmarl
$ python run.py +algorithm=ac env.name="lbforaging:Foraging-8x8-2p-3f-v2" env.time_limit=25
miniconda3/envs/venv39/lib/python3.9/site-packages/gym/spaces/box.py:73: UserWarning: WARN: Box bound precision lowered by casting to float32
  logger.warn(
(11212) [WARNING] - (09/15 15:05:27) - root >> No seed has been set.
Policy(
  (actor): MultiAgentFCNetwork(
....

Maybe gym==0.21.0 should be added to the requirements? And maybe, in general, just providing a docker image would be best or is there some limitation for why this isn't practical?

In either case, I can close this out as I got things to work on both macos and linux, thanks.

from codebase.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.