Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to successfully run a demo #1015

Open
zhiyu2020 opened this issue Dec 28, 2023 · 12 comments
Open

How to successfully run a demo #1015

zhiyu2020 opened this issue Dec 28, 2023 · 12 comments
Assignees
Labels
build/test documentation question Further information is requested

Comments

@zhiyu2020
Copy link

Hello, i have following problems.
First of all, i want to try demo to see the process of the whole infrastructure. But in the example part, it seems that the documentation is not clear. I don't know how to run demo successfully after installing tianshou with pip.
Please give detailed documentation about using example demo so that i can see how to run successfully.
image

@Trinkle23897
Copy link
Collaborator

Please use source code installation, i.e. pip install -e .
We did a major refactor few months ago, and didn’t update the pypi wheel. cc @MischaPanch

@MischaPanch
Copy link
Collaborator

FYI: Release of the wheel in next version is planned for late January or early February

@MischaPanch
Copy link
Collaborator

If you clone the repo, the surest say to install is with poetry, e.g. using poetry install

@MischaPanch MischaPanch added the question Further information is requested label Dec 28, 2023
@dantp-ai
Copy link
Contributor

My system is:

  • macOS 13.6.3
  • Python
    >>> import sys
    >>> print(sys.version, sys.platform)
    3.11.7 (main, Dec 27 2023, 17:48:28) [Clang 15.0.0 (clang-1500.1.0.2.5)] darwin
    

  • I tried running the same demo from above, after having installed the dependencies with poetry like so: poetry install --all-extras --with dev (without the extras, opencv-python and atari-py are not being installed).

  • For running this demo, I had to additionally install manually pip install gymnasium[atari] and pip install gymnasium[accept-rom-license]. I also had to manually install pip install cmake

  • envpool fails to install:

    ERROR: Could not find a version that satisfies the requirement envpool (from versions: none)
    ERROR: No matching distribution found for envpool
    
    • This seems to be an issue with envpool reported also on its Issues board here.
  • After all this, when running python atari/atari_rainbow.py the program seems to be stuck because I get intermittently the message that ALE is loaded

    A.L.E: Arcade Learning Environment (version 0.8.1+53f58b7)
    [Powered by Stella]
    

@MischaPanch
Copy link
Collaborator

MischaPanch commented Dec 28, 2023

Thank you a lot for going through the installation and looking into this! I will check the atari example in particular and address the installation details, such that everything is installed at once with the extras.

Could you please also try mujoco or one of the other environments? Atari is a particularly complicated one, the problems might be due to gymnasium (on mac) and not due to tianshou

@dantp-ai
Copy link
Contributor

Yes. I'll try it on a different environment.

Regarding envpool issue, meanwhile I found out that it does not work because there is no support for Mac currently (here and [Feature Request] Py3.10, Windows and MacOS support).

@Trinkle23897
Copy link
Collaborator

Trinkle23897 commented Dec 29, 2023

It should be configured properly as if it doesn't find a successful envpool import, it would fall back to gymnasium implementation in tianshou's atari example.

@dantp-ai
Copy link
Contributor

dantp-ai commented Dec 29, 2023

I was able to run on macOS the example under box2d/acrobot_dualdqn.py.

I tried also to run mujoco/mujoco_sac.py, but so far no luck on macOS Ventura. It seems that gcc@9 doesn't compile on macOS versions higher than Monterey:

$ brew install gcc@9
...
gcc@9: This formula either does not compile or function as expected on macOS
versions newer than Monterey due to an upstream incompatibility.
Error: gcc@9: An unsatisfied requirement failed this build.

@dantp-ai
Copy link
Contributor

On a Ubuntu-based machine I was more successful.

OS

Distributor ID: Ubuntu
Description:    Ubuntu 20.04.6 LTS
Release:        20.04
Codename:       focal

Python

>>> import sys
>>> print(sys.version, sys.platform)
3.11.7 (main, Dec 29 2023, 19:47:35) [GCC 9.4.0] linux

I successfully ran box2d/acrobot_dualdqn.py, python atari_dqn.py --task "PongNoFrameskip-v4", python mujoco_sac.py.

After having followed the steps in the Contributions section, I had to additionally do:

  • poetry install --all-extras
  • apt-get update && apt-get install -y python3-opencv

@MischaPanch
Copy link
Collaborator

As I suspected, the problem lies mainly in gymnasium and not in tianshou. I'll extend the readme and the pyproject to better deal with macos. Weirdly, the tests in CI on macos run through without envpool problems. Maybe we should extend them as well

@opcode81
Copy link
Collaborator

opcode81 commented Jan 10, 2024

We need to improve the developer docs in general and provide instructions that enable an installation of an environment that supports the full range of tasks.

For instance, in order to be able to install a Python env that supports Atari, one may need to install system-level depenendencies cmake and zlib1g prior to the Poetry install (on Ubuntu, apt-get install cmake zlib1g-dev).
Afterwards, I had to run pip install gymnasium[atari] and, for the game ROMs to be pullable, I had to run pip install gymnasium[accept-rom-license]. The poetry extra atari is not sufficient, unfortunately.

@maxhuettenrauch
Copy link
Collaborator

Checking in on the macOS related issues

MischaPanch added a commit that referenced this issue Feb 6, 2024
Addresses part of #1015 

### Dependencies

- move jsonargparse and docstring-parser to dependencies to run hl
examples without dev
- create mujoco-py extra for legacy mujoco envs
- updated atari extra
    - removed atari-py and gym dependencies
    - added ALE-py, autorom, and shimmy
- created robotics extra for HER-DDPG

### Mac specific

- only install envpool when not on mac
- mujoco-py not working on macOS newer than Monterey
(openai/mujoco-py#777)
- D4RL also fails due to dependency on mujoco-py
(Farama-Foundation/D4RL#232)

### Other

- reduced training-num/test-num in example files to a number ≤ 20
(examples with 100 led to too many open files)
- rendering for Mujoco envs needs to be fixed on gymnasium side
(Farama-Foundation/Gymnasium#749)

---------

Co-authored-by: Maximilian Huettenrauch <[email protected]>
Co-authored-by: Michael Panchenko <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build/test documentation question Further information is requested
Projects
None yet
Development

No branches or pull requests

6 participants