ml-agents icon indicating copy to clipboard operation
ml-agents copied to clipboard

ExternalCommunicator.cs freezing build when GetCommand() is called from Academy.cs Awake() method

Open MDReptile opened this issue 8 years ago • 7 comments

Unity 2017.3.0f3, Windows 7 64 bit, and following along with this tutorial series:

https://www.youtube.com/watch?v=-YWts_GlHCY&list=PLB5_EOMkLx_Ub1A4iHoDUx7vg37sVoL-E

I ran into an issue where as I try to run the ball example for training, and from the PPO page I try to run the step to "train the agents" the application opens in a small window, but it is all white, seemingly frozen.

I used debug.log statements through the code to find where it seems to freeze, and it makes it as far as the GetCommand() method in ExternalCommunicator.cs, and stops responding.

MDReptile avatar Dec 22 '17 15:12 MDReptile

This could have something to do with Nvidia optimus failing to use the Nvidia GPU over the Intel GPU - as unity logs show the Intel GPU is being selected.

MDReptile avatar Dec 23 '17 10:12 MDReptile

Hi @MDReptile, can you try launching UnityEnvironment in python using a different port?

awjuliani avatar Dec 23 '17 18:12 awjuliani

@awjuliani I tried several ports, it seems after it freezes, the port I used is still held open, and it complains saying it cannot connect, so I used several different ports and would switch between them as I tested why it was crashing.

MDReptile avatar Dec 24 '17 04:12 MDReptile

Ok - I think I've made some progress on this issue. I was concerned the optimus on my machine isn't working, and I always saw the intel card as being selected by unity in the log outputs.

So what I've tried to do, is using a batch file to temporarily disable, then re-enable to intel card, I've been able to get unity to select the nvidia card.

This causes another problem, where the resizing of the window causes the game to crash (it can't resize because the screen is blank, as the intel card is the buffer for the nvidia card). I think I may be able to get it working if I can prevent the resizing of the screen through code, so I'll report back what happens with further testing.

MDReptile avatar Dec 24 '17 05:12 MDReptile

Thanks for exploring this and reporting your results, @MDReptile. We don't have access to a dual intel/nvidia laptop on our team, so we haven't gotten a chance to test it with that set-up. If you happen to figure out how to ensure it works under those conditions, we can share them on the documentation to help out others with the same set-up.

awjuliani avatar Dec 26 '17 16:12 awjuliani

I had thought I'd gotten to the bottom of this.

Turns out, my notebooks nvidia GPU isn't even capable of doing this :)

I have a video card that supports compute 2.1 version - which unfortunately is too old, as they require 3.0 or higher compatibility for tensorflow-gpu.

This means I'm limited to doing CPU based training only - and I discovered that when I tried this out on a desktop which also has a similar video card, and also only supports compute 2.1, which means I'll need to upgrade that desktops video card in order to use GPU compute for training the agents.

A list of video cards and what versions they support (for users facing this problem): https://developer.nvidia.com/cuda-gpus

EDIT: Actually - I've noticed that even using CPU tensorflow, that I get the same problem, when launching the training the normal way through jupyter, where GetCommand() is the last method called before it freezes the unity window. I installed CPU tensorflow using this method: https://software.intel.com/en-us/articles/explore-unity-technologies-ml-agents-exclusively-on-intel-architecture

And I discovered I can launch the training directly from python using "python ppo.py <env_name> --train" as I found here: https://github.com/Unity-Technologies/ml-agents/issues/13

Not sure why it freezes unity if the training is started through the normal way?

EDIT2: Tried switching to Unity 2017.1.2f1 instead of 2017.3 and that made no difference.

And at this point if I do "jupyter notebook" and then open the PPO, start doing the steps, it will make it to "train the agents" where it launches the unity window, never resizes it, it just stays white, and shows "not responding" until I kill the process.

The only way so far to get training to work is through the python command. I have yet to figure out a way to export the trained model after using the python command, or I'd try to just skip the whole jupyter part.

Can't figure what else to try. Heres some info on the setup: -Win 7 64 bit -Unity 2017.1.2f1 OR 2017.3 -tensorflow-cpu -no splash screen for the exe

EDIT3: Finally got it to work through jupyter. I'm not sure really what combination of tinkering I did to get it working, but I built out an exe, ran the jupyter notebook, and now it seems to let me train and hopefully export a model. I'd say that if others are having similar problem freezing when your going through the steps, make sure to take your time and let the notebook kernel get connected for a few moments before you start running the steps, then when you reach the part where you launch the envirornment, click next (so it selects the training header area) and this will bring up the window for the unity build. Once this happens wait a moment again until you see that it starts successfully (a little red pop up under the launching script area says "successfully started environment" or something similar. Once that pops up, you can then hit next and run the training, and hit next again to have it select the title to the export area. Once you do this, the training should hopefully start if everything is set up correctly!

MDReptile avatar Dec 27 '17 17:12 MDReptile

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock[bot] avatar Jan 04 '20 20:01 lock[bot]