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

Unity environment freezing on launch #13

Closed
AndreTInfante opened this issue Sep 21, 2017 · 11 comments
Closed

Unity environment freezing on launch #13

AndreTInfante opened this issue Sep 21, 2017 · 11 comments
Labels
help-wanted Issue contains request for help or information.

Comments

@AndreTInfante
Copy link

I've got to the point that I can successfully launch the 3D ball example. However, when I run the jupyter notebook file and the app starts automatically, it starts a tiny window and then freezes, and has to be process killed (see image below). Jupyter notebook doesn't show any errors, so I'm not entirely sure what's up. Any ideas as to how to fix this?

image

Thank you!

@eagleEggs
Copy link

The small window is expected as it's set in the scene to train at that window size (128x72). Likely to make performance better while it's crunching the PPO. I have noticed on my system that it seems to freeze, while still actually crunching away. Check Tensorflow to see if it continues to update, also Jupyter updates the mean reward below the training code chunk as it progresses. Also, if it turns out to be resource related, maybe remove some of those balls/platforms from the scene and then rebuild.

Overall, this demo is pretty intensive and I'm guessing that watching the game window while it's crunching probably isn't feasible unless you're on a decent rig (I have 8GB RAM I7 and still can barely watch the game window during this specific PPO), but even then watching it is just wasting resources :/

@romerocesar romerocesar added the help-wanted Issue contains request for help or information. label Sep 21, 2017
@JZito
Copy link

JZito commented Sep 21, 2017

Same problem but am able to launch Unity Environments successfully by launching the python scripts directly.

Following the wiki Balance Balls walkthrough, launching the environments from the Basics or PPO Jupyter Notebooks, Unity Environment will launch, display the Built by Unity logo and then hang with a black screen.
This is after commenting out signal-related content from the environment.py file, as referenced here: #5
Here is the output log:

Mono path[0] = 'C:/Documents/Unity/ml-agents/python/test2_Data/Managed'
Mono config path = 'C:/Documents/Unity/ml-agents/python/test2_Data/MonoBleedingEdge/etc'
PlayerConnection initialized from C:/Documents/Unity/ml-agents/python/test2_Data (debug = 0)
PlayerConnection initialized network socket : 0.0.0.0 55248
Multi-casting "[IP] 192.168.1.130 [Port] 55248 [Flags] 2 [Guid] 3478566033 [EditorId] 2953059523 [Version] 1048832 [Id] WindowsPlayer(DESKTOP-NQ9QNAK) [Debug] 0" to [225.0.0.222:54997]...
Started listening to [0.0.0.0:55248]
PlayerConnection already initialized - listening to [0.0.0.0:55248]
Player data archive not found at C:/Documents/Unity/ml-agents/python/test2_Data/data.unity3d, using local filesystem
Initialize engine version: 2017.1.1f1 (5d30cf096e79)
GfxDevice: creating device client; threaded=1
Direct3D:
Version: Direct3D 11.0 [level 11.0]
Renderer: NVIDIA GeForce GTX 960M (ID=0x139b)
Vendor: NVIDIA
VRAM: 4064 MB
Driver: 21.21.13.7633
Begin MonoManager ReloadAssembly
Loading C:\Documents\Unity\ml-agents\python\test2_Data\Managed\UnityEngine.dll into Unity Child Domain
Platform assembly: C:\Documents\Unity\ml-agents\python\test2_Data\Managed\System.Core.dll (this message is harmless)
Loading C:\Documents\Unity\ml-agents\python\test2_Data\Managed\Assembly-CSharp.dll into Unity Child Domain
Loading C:\Documents\Unity\ml-agents\python\test2_Data\Managed\UnityEngine.UI.dll into Unity Child Domain
Loading C:\Documents\Unity\ml-agents\python\test2_Data\Managed\UnityEngine.Networking.dll into Unity Child Domain
Loading C:\Documents\Unity\ml-agents\python\test2_Data\Managed\UnityEngine.Timeline.dll into Unity Child Domain
Loading C:\Documents\Unity\ml-agents\python\test2_Data\Managed\Newtonsoft.Json.dll into Unity Child Domain
Platform assembly: C:\Documents\Unity\ml-agents\python\test2_Data\Managed\System.dll (this message is harmless)

  • Completed reload, in 0.048 seconds
    Initializing input.

Input initialized.

Initialized touch support.

UnloadTime: 1.216441 ms
Platform assembly: C:\Documents\Unity\ml-agents\python\test2_Data\Managed\System.Configuration.dll (this message is harmless)
Platform assembly: C:\Documents\Unity\ml-agents\python\test2_Data\Managed\System.Xml.dll (this message is harmless)
Platform assembly: C:\Documents\Unity\ml-agents\python\test2_Data\Managed\Mono.Security.dll (this message is harmless)
Platform assembly: C:\Documents\Unity\ml-agents\python\test2_Data\Managed\System.Data.dll (this message is harmless)

Once you force quit the program, the log is filled with cascading socket exceptions:

SocketException: An established connection was aborted by the software in your host machine.

I was able to successfully launch the environment running the python script directly with "python ppo.py <env_name> --train".

@awjuliani
Copy link
Contributor

Thanks for trying this out, everyone.

It is indeed the case that running in a small window, and low frame-rate are expected behavior. This is in order to allow the game to run at 100x speed, and provide as much training data as possible. If this is creating issues on your device, I would recommend trying to decrease the Time Scale under Training Configuration of the Academy object in the scene to something like 10. See https://github.com/Unity-Technologies/ml-agents/wiki/Agents-Editor-Interface#academy for more details. While this will slow training, it will also provide more visual feedback that the environment is running as expected.

The black screen hang that you are experiencing @JZito might be due to the environment not resetting yet. Try running a block of code in Basic.ipynb which runs env.reset(), and see if the screen is still black.

@AndreTInfante
Copy link
Author

AndreTInfante commented Sep 21, 2017

Hmm. I slowed down the time scale to 5 for debugging purpose, and I could see it going. But after a second or two the pixels on screen stopped moving and it froze. I was watching it in jupyter notebook, and it was showing new rewards until the freeze, at which point it stopped.

image

Which leads me to think this is an actual crash, and not just unresponsive UI.

(For reference, I'm running this on a 64-bit i5 4595, without CUDA/gpu support for the time being)

@AndreTInfante
Copy link
Author

Nevermind, I'm an idiot, I needed to increase the number of episodes. Thanks for your help!

@awjuliani
Copy link
Contributor

Glad you were able to get things working!

@gautam1858
Copy link

@awjuliani Can you please tell me how to reduce the time scale ?

@quantumiracle
Copy link

Hi,
I also meet this problem that launching from the python script or jupyter notebook as here for a self-built env will stuck at a small screen. And it seems it stucks before or at the env.reset() step. I've made the timescale to be 1 for training, but it still stucks. Do you guys know what's wrong with it?

@jialululu
Copy link

jialululu commented Aug 31, 2019

Hi there,
we also came across similar problems. The code hangs after we run the env.reset() block. and in the small window, we could still control the angle we see using our mouses. The whole program just gets stuck on the reset part. Does anyone have any idea what kind of error we are running into? And we checked the brain attached to the agent, or any solutions above. None of them has worked yet.

@awjuliani
Copy link
Contributor

Hi all. To have the simulation proceeds from python, you must call env.step() from python. Unity will wait otherwise for the action from python. If you'd like to run in a simple loop, you can call env.step() without passing any actions. Otherwise, you would compute actions for the agents in your scene to take.

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help-wanted Issue contains request for help or information.
Projects
None yet
Development

No branches or pull requests

8 participants