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

Procgen Integration #197

Merged
merged 58 commits into from
Jan 3, 2023
Merged

Procgen Integration #197

merged 58 commits into from
Jan 3, 2023

Conversation

YukunJ
Copy link
Collaborator

@YukunJ YukunJ commented Sep 16, 2022

Description

Continued Procgen integration progress with @LeoGuo98 together.

A few things:

  1. globalGameRegistry somehow doesn't successfully register each game while bazel build & compile. Temporary solution is just write a patch for each game to return a shared_ptr in this commit.

  2. The batch size for the StateBufferQueue seems to be 0, even if we set it explicitly, which leads to division by zero error. We haven't figured out what's the cause behind it. The env._recv() and env._reset() is the "crash entry point". See details comments in this commit. Trinkle points out that it's probably a memory allocation issue regard to array indexing.

  3. There is also some problem with loading the game background picture. Currently by setting game_->options.use_generated_assets = true; to avoid such loading. But not sure it it would have adverse effect later on.

  4. Currently when stepping, we see different RGB 64*64 observations, meaning the game character is indeed moving.

  5. We fix the problem with IsDone always being True. The game could works. And cv2.imwrite() we export the rgb 64x64x3 pictures for verification. It does look correct.

  6. We finished deterministic and alignment test on procgen raw environment and Envpool's environment with gym and dmc

  7. We supported build environment from scratch on Ubuntu 22.04 LTS (solved QT path dependency problem) (a raw new Ubuntu needs sudo apt update && sudo apt install qt5-default && sudo apt-get install qtdeclarative5-dev to install necessary QT dependency for Procgen compilation

PROBLEM AT HAND:

  • Cannot pip install procgen in the Bazel sandbox, because original procgen folder has empty space in between folder name.

Solution now:

  • Out sourcing the procgen repo to my own github fork and make modification there. see link

Progress:

  • Able to build the me-modified procgen on new AWS Ubuntu 20.04 LTS instance.
  • Able to pip install procgen@git+https://github.com/YukunJ/procgen.git and enter Python to import this procgen library and make environments (both on AWS instance and my local MacOS)

But, on the github testing machine, when building the project, it gives the error of links

...
File "/home/ubuntu/.cache/bazel/_bazel_ubuntu/0afe9dcfb3afec104db6df7ee3f95f3c/external/pypi__setuptools/setuptools/_distutils/dist.py", line 986, in run_command
          cmd_obj.run()
        File "/tmp/pip-wheel-3u_a5q_c/procgen_c19c3bc9b11045eb8ba9f6db8928ae4c/setup.py", line 65, in run
          import builder
        File "/tmp/pip-wheel-3u_a5q_c/procgen_c19c3bc9b11045eb8ba9f6db8928ae4c/procgen/builder.py", line 11, in <module>
          import gym3
      ModuleNotFoundError: No module named 'gym3'

even if I add the requirements.txt

...
gym3
procgen@git+https://github.com/YukunJ/procgen.git

But I don't have this problem building Envpool project from stratch on AWS Instance. I am able to execute the following command:

// Start a new AWS Instance Ubuntu 22.04 LTS

// Ubuntu Basic Build Tool Support
sudo apt update &&
sudo add-apt-repository ppa:ubuntu-toolchain-r/test &&
sudo apt install -y gcc-9 g++-9 build-essential &&
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 60 --slave /usr/bin/g++ g++ /usr/bin/g++-9 &&
sudo apt install -y python3-dev python3-pip &&
sudo ln -sf /usr/bin/python3 /usr/bin/python &&
sudo apt update && sudo apt install qt5-default && 
sudo apt-get install qtdeclarative5-dev
sudo apt install -y python3-dev python3-pip
sudo ln -sf /usr/bin/python3 /usr/bin/python

// Install my 3rd Procgen
pip uninstall procgen
pip install procgen@git+https://github.com/YukunJ/procgen.git

// Run Procgen in Python
$ python3
>>> import gym
>>> import procgen
>>> import numpy as np
>>> procgen_gym = gym.make("procgen:procgen-bigfish-v0", rand_seed=0, use_generated_assets=True)
>>> procgen_gym.reset()
>>> num_env, act_space = 1, procgen_gym.action_space
>>> step_count = 0
>>> raw_done = False
>>> while (not raw_done):
	action = np.array([act_space.sample() for _ in range(num_env)])
	_, raw_reward, raw_done, _ = procgen_gym.step(action[0])
	step_count += 1
	print("Step=", step_count)

YukunJ and others added 30 commits September 4, 2022 18:06
Some variable naming changes correspond to master changes in May
@brief: patch the compile-build for returning a pointer to a new game instance
Originally, we want to use globalGameRegistry to get back a game instance by providing the game name (std::string)
However, somehow this pointer a map->func is nullptr, not properly registered each game (don't know why)
Current solution is in each game .cpp file to patch a function that return an instance of this game.

For now, only patch the bigfish game to move forward
add factory method for each game and a central game getter
Progress: by advice from Jiayi, fix self-allocated buffer's memory bug
Now able to compile and run the environment

However, the result is not as expected: each step always stuck in the same state, regardless of the action passed in

Plus:'make format' applied to format the code
by providing specific low_seed and high_seed, we see different rgb 64*64 observations each step
which means the game character is running
but the is_done field is always true and we don't see reward > 0 ever
there should still be some problems with that part, to be investigated
explicitly set the 'done_' field to false in the Reset() function

raw env is able to run seemingly properly

For example, stats:

I0929 14:00:05.346351 140379074299712 procgen_py_test.py:80] Total steps 5000 yieds 52 times of reset and total rewards of 9.0
I0929 14:00:05.346710 140379074299712 procgen_py_test.py:81] Raw envpool Procgen FPS = 743.639040

This looks good to me
though i might mis-order the RGB 3 indexes, but generally the game's picture is moving correctly as I slide through a few hundred steps
Finish the alignment test for procgen set of games in envpool
Now all functionality and test suites are ready and working properly

One last thing is to revise the system platform compatibilityon Ubuntu 22.04 LTS
as previously Trinkle found out that the QT library path is somewhat messed up and cannot build on Ubuntu 22.04 LTS
* Change Path to QT on Ubuntu 20.04

* Update assetgen.patch for new qt library path

* Update assetgen.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Swap include order

* Swap Header order

* turn off clang-format for two specific lines

* clang-format & lint
* Change Path to QT on Ubuntu 20.04

* Update assetgen.patch for new qt library path

* Update assetgen.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Swap include order

* Swap Header order

* turn off clang-format for two specific lines

* clang-format & lint

* pylint

* pylint

* temp

* Update: add hints for library build

* Format

* Format

* Format

* Format

* Format

* Format

* Format

* Format

Co-authored-by: Ubuntu <ubuntu@ip-172-31-17-244.ec2.internal>
* Change Path to QT on Ubuntu 20.04

* Update assetgen.patch for new qt library path

* Update assetgen.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Swap include order

* Swap Header order

* turn off clang-format for two specific lines

* clang-format & lint

* pylint

* pylint

* temp

* Update: add hints for library build

* Format

* Format

* Format

* Format

* Format

* Format

* Format

* Format

* Format

Co-authored-by: Ubuntu <ubuntu@ip-172-31-17-244.ec2.internal>
* Change Path to QT on Ubuntu 20.04

* Update assetgen.patch for new qt library path

* Update assetgen.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Swap include order

* Swap Header order

* turn off clang-format for two specific lines

* clang-format & lint

* pylint

* pylint

* temp

* Update: add hints for library build

* Format

* Format

* Format

* Format

* Format

* Format

* Format

* Format

* Format

* Fix

Co-authored-by: Ubuntu <ubuntu@ip-172-31-17-244.ec2.internal>
* Change Path to QT on Ubuntu 20.04

* Update assetgen.patch for new qt library path

* Update assetgen.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Swap include order

* Swap Header order

* turn off clang-format for two specific lines

* clang-format & lint

* pylint

* pylint

* temp

* Update: add hints for library build

* Format

* Format

* Format

* Format

* Format

* Format

* Format

* Format

* Format

* Fix

* Fix DocString

Co-authored-by: Ubuntu <ubuntu@ip-172-31-17-244.ec2.internal>
* Change Path to QT on Ubuntu 20.04

* Update assetgen.patch for new qt library path

* Update assetgen.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Swap include order

* Swap Header order

* turn off clang-format for two specific lines

* clang-format & lint

* pylint

* pylint

* temp

* Update: add hints for library build

* Format

* Format

* Format

* Format

* Format

* Format

* Format

* Format

* Format

* Fix

* Fix DocString

* Fix: space

* Pip install procgen

Co-authored-by: Ubuntu <ubuntu@ip-172-31-17-244.ec2.internal>
* Change Path to QT on Ubuntu 20.04

* Update assetgen.patch for new qt library path

* Update assetgen.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Swap include order

* Swap Header order

* turn off clang-format for two specific lines

* clang-format & lint

* pylint

* pylint

* temp

* Update: add hints for library build

* Format

* Format

* Format

* Format

* Format

* Format

* Format

* Format

* Format

* Fix

* Fix DocString

* Fix: space

* Pip install procgen

* Fix format

Co-authored-by: Ubuntu <ubuntu@ip-172-31-17-244.ec2.internal>
* Change Path to QT on Ubuntu 20.04

* Update assetgen.patch for new qt library path

* Update assetgen.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Swap include order

* Swap Header order

* turn off clang-format for two specific lines

* clang-format & lint

* pylint

* pylint

* temp

* Update: add hints for library build

* Format

* Format

* Format

* Format

* Format

* Format

* Format

* Format

* Format

* Fix

* Fix DocString

* Fix: space

* Pip install procgen

* Fix format

* Fix missing dependency

* format

* Try fix

Co-authored-by: Ubuntu <ubuntu@ip-172-31-17-244.ec2.internal>
* Change Path to QT on Ubuntu 20.04

* Update assetgen.patch for new qt library path

* Update assetgen.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Swap include order

* Swap Header order

* turn off clang-format for two specific lines

* clang-format & lint

* pylint

* pylint

* temp

* Update: add hints for library build

* Format

* Format

* Format

* Format

* Format

* Format

* Format

* Format

* Format

* Fix

* Fix DocString

* Fix: space

* Pip install procgen

* Fix format

* Fix missing dependency

* format

* Try fix

* Remove procgen dependency

Co-authored-by: Ubuntu <ubuntu@ip-172-31-17-244.ec2.internal>
* Change Path to QT on Ubuntu 20.04

* Update assetgen.patch for new qt library path

* Update assetgen.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Swap include order

* Swap Header order

* turn off clang-format for two specific lines

* clang-format & lint

* pylint

* pylint

* temp

* Update: add hints for library build

* Format

* Format

* Format

* Format

* Format

* Format

* Format

* Format

* Format

* Fix

* Fix DocString

* Fix: space

* Pip install procgen

* Fix format

* Fix missing dependency

* format

* Try fix

* Remove procgen dependency

* dependency

Co-authored-by: Ubuntu <ubuntu@ip-172-31-17-244.ec2.internal>
Co-authored-by: Ubuntu <ubuntu@ip-172-31-17-244.ec2.internal>
* Change Path to QT on Ubuntu 20.04

* Update assetgen.patch for new qt library path

* Update assetgen.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Swap include order

* Swap Header order

* turn off clang-format for two specific lines

* clang-format & lint

* pylint

* pylint

* temp

* Update: add hints for library build

* Format

* Format

* Format

* Format

* Format

* Format

* Format

* Format

* Format

* Fix

* Fix DocString

* Fix: space

* Pip install procgen

* Fix format

* Fix missing dependency

* format

* Try fix

* Remove procgen dependency

* dependency

* Try Gym3 Env

* Try without procen import

* Try without procen import

* Update

* Update

* Update

* Update

* Update

* Update

* update

* Do not pip install procgen

Co-authored-by: Ubuntu <ubuntu@ip-172-31-17-244.ec2.internal>
* Change Path to QT on Ubuntu 20.04

* Update assetgen.patch for new qt library path

* Update assetgen.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Swap include order

* Swap Header order

* turn off clang-format for two specific lines

* clang-format & lint

* pylint

* pylint

* temp

* Update: add hints for library build

* Format

* Format

* Format

* Format

* Format

* Format

* Format

* Format

* Format

* Fix

* Fix DocString

* Fix: space

* Pip install procgen

* Fix format

* Fix missing dependency

* format

* Try fix

* Remove procgen dependency

* dependency

* Try Gym3 Env

* Try without procen import

* Try without procen import

* Update

* Update

* Update

* Update

* Update

* Update

* update

* Do not pip install procgen

* Try link to my own Procgen repo

* Change include path

* Comment out unused vars

Co-authored-by: Ubuntu <ubuntu@ip-172-31-17-244.ec2.internal>
* Change Path to QT on Ubuntu 20.04

* Update assetgen.patch for new qt library path

* Update assetgen.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Swap include order

* Swap Header order

* turn off clang-format for two specific lines

* clang-format & lint

* pylint

* pylint

* temp

* Update: add hints for library build

* Format

* Format

* Format

* Format

* Format

* Format

* Format

* Format

* Format

* Fix

* Fix DocString

* Fix: space

* Pip install procgen

* Fix format

* Fix missing dependency

* format

* Try fix

* Remove procgen dependency

* dependency

* Try Gym3 Env

* Try without procen import

* Try without procen import

* Update

* Update

* Update

* Update

* Update

* Update

* update

* Do not pip install procgen

* Try link to my own Procgen repo

* Change include path

* Comment out unused vars

* Install Procgen from my folder

* import my procgen

Co-authored-by: Ubuntu <ubuntu@ip-172-31-17-244.ec2.internal>
* Change Path to QT on Ubuntu 20.04

* Update assetgen.patch for new qt library path

* Update assetgen.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Swap include order

* Swap Header order

* turn off clang-format for two specific lines

* clang-format & lint

* pylint

* pylint

* temp

* Update: add hints for library build

* Format

* Format

* Format

* Format

* Format

* Format

* Format

* Format

* Format

* Fix

* Fix DocString

* Fix: space

* Pip install procgen

* Fix format

* Fix missing dependency

* format

* Try fix

* Remove procgen dependency

* dependency

* Try Gym3 Env

* Try without procen import

* Try without procen import

* Update

* Update

* Update

* Update

* Update

* Update

* update

* Do not pip install procgen

* Try link to my own Procgen repo

* Change include path

* Comment out unused vars

* Install Procgen from my folder

* import my procgen

* gym3

Co-authored-by: Ubuntu <ubuntu@ip-172-31-17-244.ec2.internal>
YukunJ and others added 15 commits December 9, 2022 13:42
* Change Path to QT on Ubuntu 20.04

* Update assetgen.patch for new qt library path

* Update assetgen.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Swap include order

* Swap Header order

* turn off clang-format for two specific lines

* clang-format & lint

* pylint

* pylint

* temp

* Update: add hints for library build

* Format

* Format

* Format

* Format

* Format

* Format

* Format

* Format

* Format

* Fix

* Fix DocString

* Fix: space

* Pip install procgen

* Fix format

* Fix missing dependency

* format

* Try fix

* Remove procgen dependency

* dependency

* Try Gym3 Env

* Try without procen import

* Try without procen import

* Update

* Update

* Update

* Update

* Update

* Update

* update

* Do not pip install procgen

* Try link to my own Procgen repo

* Change include path

* Comment out unused vars

* Install Procgen from my folder

* import my procgen

* gym3

* update

* Update

* gym3

* Try tester

* wheel

Co-authored-by: Ubuntu <ubuntu@ip-172-31-17-244.ec2.internal>
* Change Path to QT on Ubuntu 20.04

* Update assetgen.patch for new qt library path

* Update assetgen.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Swap include order

* Swap Header order

* turn off clang-format for two specific lines

* clang-format & lint

* pylint

* pylint

* temp

* Update: add hints for library build

* Format

* Format

* Format

* Format

* Format

* Format

* Format

* Format

* Format

* Fix

* Fix DocString

* Fix: space

* Pip install procgen

* Fix format

* Fix missing dependency

* format

* Try fix

* Remove procgen dependency

* dependency

* Try Gym3 Env

* Try without procen import

* Try without procen import

* Update

* Update

* Update

* Update

* Update

* Update

* update

* Do not pip install procgen

* Try link to my own Procgen repo

* Change include path

* Comment out unused vars

* Install Procgen from my folder

* import my procgen

* gym3

* update

* Update

* gym3

* Try tester

* wheel

* gymnasisum

Co-authored-by: Ubuntu <ubuntu@ip-172-31-17-244.ec2.internal>
* Change Path to QT on Ubuntu 20.04

* Update assetgen.patch for new qt library path

* Update assetgen.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Swap include order

* Swap Header order

* turn off clang-format for two specific lines

* clang-format & lint

* pylint

* pylint

* temp

* Update: add hints for library build

* Format

* Format

* Format

* Format

* Format

* Format

* Format

* Format

* Format

* Fix

* Fix DocString

* Fix: space

* Pip install procgen

* Fix format

* Fix missing dependency

* format

* Try fix

* Remove procgen dependency

* dependency

* Try Gym3 Env

* Try without procen import

* Try without procen import

* Update

* Update

* Update

* Update

* Update

* Update

* update

* Do not pip install procgen

Co-authored-by: Ubuntu <ubuntu@ip-172-31-17-244.ec2.internal>
* Change Path to QT on Ubuntu 20.04

* Update assetgen.patch for new qt library path

* Update assetgen.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Update qt_utils.patch for new qt library path

* Swap include order

* Swap Header order

* turn off clang-format for two specific lines

* clang-format & lint

* pylint

* pylint

* temp

* Update: add hints for library build

* Format

* Format

* Format

* Format

* Format

* Format

* Format

* Format

* Format

* Fix

* Fix DocString

* Fix: space

* Pip install procgen

* Fix format

* Fix missing dependency

* format

* Try fix

* Remove procgen dependency

* dependency

* Try Gym3 Env

* Try without procen import

* Try without procen import

* Update

* Update

* Update

* Update

* Update

* Update

* update

* Do not pip install procgen

* Try link to my own Procgen repo

* Change include path

* Comment out unused vars

* Install Procgen from my folder

* import my procgen

* gym3

* update

* Update

* gym3

* Try tester

* wheel

* gymnasisum

* update

* LICENSE

Co-authored-by: Ubuntu <ubuntu@ip-172-31-17-244.ec2.internal>
@Trinkle23897 Trinkle23897 changed the title Procgen Integration Draft Procgen Integration Jan 2, 2023
@Trinkle23897 Trinkle23897 marked this pull request as ready for review January 2, 2023 20:11
@Trinkle23897 Trinkle23897 linked an issue Jan 2, 2023 that may be closed by this pull request
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] Procgen integration
2 participants