facebookresearch / nle

The NetHack Learning Environment
Other
939 stars 114 forks source link

Getting my algorithm to play Nle #245

Closed Shikamaru5 closed 2 years ago

Shikamaru5 commented 3 years ago

So I've been trying for awhile to get my algorithm to play Nethack. I very well could've overlooked something and thus I am seeing if anyone has any advice, that would help me solve this. It might be a really simple solution and I hope it is, but at this point I can't seem to find it.

What I'm currently trying, is that I have the docker container fairnle/nle-focal pulled and is on my machine. It always runs when I input the command winpty docker run -it fairnle/nle-focal, and then it provides me with the output root@afee29945e97:/workspace, in which I respond with python -m nle.scripts.play -e NetHackChallenge-v0

I have my file that has my algorithm waiting to be trained in sublime text, and when I input python 'myfile.py' (without the airquotes). It outputs (base) and gitbash waits for my next instruction.

So upon doing a thorough investigation I have figured perhaps like it says on the aicrowd nethackchallenge site, that I need to git clone http://gitlab.aicrowd.com/nethack/neurips-2021-the-nethack-challenge.git \ && cd neurips-2021-the-nethack-challenge \ && git lfs install \ && git lfs pull and then: winpty docker run -it -v `pwd`:/home/aicrowd --gpus 'all' fairnle/challenge:dev but with my own inputs, although just testing this, it doesn't work for me. I get given the output: docker: Error response from daemon: OCI runtime create failed: invalid mount {De stination:\Program Files\Git\home\aicrowd Type:bind Source:/run/desktop/mnt/host /c/Users/Kalvin/Desktop/NLE/neurips-2021-the-nethack-challenge;C Options:[rbind rprivate]}: mount destination \Program Files\Git\home\aicrowd not absolute: unkn own. (base)

It very well could be that I just don't understand what it's doing when I input that into my computer. However, my thought was to make a folder and put my files into it for the algorithm, insert it into the neurips-2021-the-nethack-challenge folder, and cd to 'Algo' folder, and then run python 'myfile.py'. It again just outputs (base), which I figure is at least an ok sign that the algorithm is still functioning in some opaque capacity.

Next I tried to figure out what in the run might be what I require to add or change to make it operate the way I need. I've tried doing winpty docker run -it -v myfile.py fairnle/challenge:dev, it outputs that there is a daemon error and it was an invalid mount , which happens similarly if I do winpty docker run -it -v fairnle/challenge:dev python myfile.py .

I've done variations on this theme trying new inputs, and removing, and changing folders, but at the end of the day it seems for some reason it doesn't recognize my 'myfile.py' in any sort of file or directory even when I explicitly change directories to be exactly where it is, or to even have it not be in a directory and just have it on the desktop.

From doing research perhaps it's a problem with the path line because it was suggested in the output code once or twice that /opt/conda/bin/python: the relative module names not supported. Or it's told me $PATH cannot find the directory or file. I've tried it with fairnle/nle-focal with similar disappointments.

Trying lines like winpty docker run -it fairnle/nle-focal -m myfile.py -e NetHackChallenge-v0, to no avail. For a little while I figured it was an issue with port connections, after all it's a great way for containers to listen to eachother, but it is also really unsecure so I understand the trepidation with allowing access to them. However, I was watching a video of a guy using the openai gym universe docker to have his algorithm play a racing game, and didn't require that kind of access to do that so I got off the port train of thought. Which led me to this current line of inquiry.

I tried it his way with using openai gym's universe to try and load in the nle docker container but it also led to the same thing so after all this I'm led to believe that I've somehow not defined where my file path is, and hopefully if I can do that it'll run.

My other worry is that when I try to run a file and the docker container at the same time, it'll either run the algorithm or the game but never simultaneously which is what I'm currently attempting to do. I feel like they try to bowl eachother over, and if they succeed, they sometimes don't output anything.

Now I know this has been a long read but please bare with me on this journey because this isn't the only thing I've tried to get things to work. I have also created a virtual machine with the os ubuntu, and have tried getting things to run on there, I went as far as I could with that but using the processes defined on the site, I keep getting denied permissions, such as to clone the repo to get nle, and just pip installing nle, still outputs the same issue with the wheels PEP 517. So I attempted to do docker on that one to see if the issue was with gym not liking windows and I stuck me with the same file destination problem.

I'm unfamiliar with the C++ language so trying to rebuild the entire game for PyGame is just going to take to much time, and it isn't guaranteed that you'd accept that game even if I did rebuild it. What frustrates me is that I can download the game and play it on my wsl2 no problem or I can play it on my docker no problem, I just can't seem to find a good way to get my algorithm to interact with them. I considered maybe trying to learn some way of getting the algorithm to access my keyboard and monitor view screen like openai gym universe and play either the nle docker container that way or the wsl2 nethack game that way but I think come submission time problems may arise with the NetHack solution, and I think it's relatively the same file problem trying to do it the docker way.

Anyway again, it's been a long ride, and maybe after all this I've overlooked a super simple way of doing this, and I'd be more than happy to accept any help, anybody could offer. Perhaps this whole issue I've created is incoherent jargon but after hundreds of different thoughts and possible solutions, I'm fairly stumped on why I can't get my Ai to interact with a docker container, or even the right question to ask online or on YouTube. I really appreciate you taking the time to read this and I hope you can help.

Very much appreciated,

Shikamaru5

Shikamaru5 commented 3 years ago

After mulling it over, and thinking up new options, I believe I have discovered at least where the problem lies, when I run my script after the docker container fairnle/nle-focal I think it is trying to search for it in env conda dir opt/conda. This of course doesn't work because it isn't located there, it is located in a completely different directory. When I looked into the docker container it showed that an env path was created, but I'm uncertain as to whether or not I need to be creating directories for opt, conda, and bin? Well and the env path looks like this I believe, ENV PATH ${CONDA_DIR}/bin:${PATH}. Or should I be trying to add opt/conda/bin to the path line in environment variables on my computer? Any help would very much be appreciated.

Thank you for taking the time to read this,

Shikamaru5

Shikamaru5 commented 3 years ago

So after taking the time to do a bunch more research I think what I'm supposed to do is bind mount my file to the docker container. Which seems straight forward enough I pulled fairnle/nle-focal onto my host machine, I made my algorithm, and put it in it's own directory. Then I run winpty docker run -it -v /c/Users/MyName/desktop/Ne:/opt/conda/bin fairnle/nle-focal python NMNH.py and as far as I can tell it should run. Unfortunately it tells me this; python: can't open file 'NMNh.py': [Errno 2] No such file or directory. Which leads me to believe maybe, I've missed what the absolute path to the Docker container is but even if I substitute both paths for, $(pwd):/wd it still gives me that error. Have I missed something fundamental, or am I doing it mostly right and there's just a little tweak I have to make for it to run? I'm not trying to be a pain, it's just odd that I can't seem to get docker to work for me even though it should be a fairly simple process, as far as I can tell.

As always, thank you for taking the time to read,

Shikamaru5