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

Custom gym environment support #53

Open
lucalazzaroni opened this issue Feb 2, 2021 · 6 comments
Open

Custom gym environment support #53

lucalazzaroni opened this issue Feb 2, 2021 · 6 comments

Comments

@lucalazzaroni
Copy link

I'm currently working on a project (branching from this) where I created a new gym environment adding policies for autonomous driving in a highway. I defined my own reward weights for each of the actions the agent could take, so I would like to evaluate them, in order to get an optimal value for the reward function and, then, perform a DQN. My question is if your tool supports or not custom gym environments and, if so, how could I exploit it. I tried your notebook in colab but there's a problem with the python version, so I installed it on linux but I don't get how to implement it in my code.
Thanks in advance for your help.

@AdamGleave
Copy link
Member

So long as the environments implement the standard Gym interface it should work fine with this code. In the notebook, all you need to do is replace gym.make(env_name) with whatever is needed to create your environment. (If your environments are registered in the Gym registry, then you just need to change env_name.)

The trickiest part will probably be getting the reward models you're using hooked up to the code -- it needs to follow the API here. It sounds like you're just comparing hand-designed reward functions, as opposed to learned reward models? In that case you might find PointMassGroundTruth a useful example of defining your own reward function.

The Colab issue I assume is because it only supports Python 3.6? It should run fine locally in Jupyter notebook, let me know if you run into any issues with the notebook.

@lucalazzaroni
Copy link
Author

Thanks for the infos, I'll give it a try in the next few days. Meanwhile I opened the notebook locally with Jupyter but when it executes the line importing tensorflow a "kernel died" message prompts and the notebook restarts. I tried all the tensorflow 1.15.x versions but he problem persists. Any idea about it? I'm using Ubuntu 20.04.2 LTS from Oracle VirtualBox.

@AdamGleave
Copy link
Member

Thanks for the infos, I'll give it a try in the next few days. Meanwhile I opened the notebook locally with Jupyter but when it executes the line importing tensorflow a "kernel died" message prompts and the notebook restarts. I tried all the tensorflow 1.15.x versions but he problem persists. Any idea about it? I'm using Ubuntu 20.04.2 LTS from Oracle VirtualBox.

Interesting, not a failure mode I've seen before. I'd suggest running ./scripts/build_venv.sh venv from the project root directory. This should install the same versions of everything we use for our continuous integration. Then . ./venv/bin/activate, pip install jupyter and try running the Jupyter notebook from there. If you're still seeing issues, can you import tensorflow OK outside of Jupyter?

It's worked on Ubuntu 20.04 in the past so that should be supported, although I've never tried inside VirtualBox. I could imagine that causing problems if TensorFlow is trying to use GPU for example. But otherwise should run fine.

@lucalazzaroni
Copy link
Author

I followed the steps you suggested but the error persists, So i tried to import tensorflow outside jupyter but it returns me Illegal instruction (core dumped). At this point I think the problem could be VirtualBox

@AdamGleave
Copy link
Member

AdamGleave commented Feb 4, 2021 via email

@lucalazzaroni
Copy link
Author

Hi @AdamGleave, sorry for my late response, I tried to compile tensorflow from source but no luck. I think I'll try again with colab and see if there's any possibility to use it along with python 3.7 instead of 3.6.

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

No branches or pull requests

2 participants