-
Notifications
You must be signed in to change notification settings - Fork 212
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
Multithreading frequent calls is crashing #46
Comments
Do you want any help in replicating the bug? I can share you a small project where you can replicate the bug. |
That would be helpful! I suspect some race condition is occurring, but that would be weird because python uses a global interpreter lock, perhaps I'm not doing something quite right. Note to self: c++ function used for this is found at https://github.com/getnamo/UnrealEnginePython/blob/master/Source/UnrealEnginePython/Private/UEPyEngine.cpp#L814 Note2: this is new https://github.com/20tab/UnrealEnginePython/blob/0393f40181988789eeec95d1cd9d6eec811ec2a2/android/python27/include/ceval.h#L79, do we need to wrap our function with it? |
I have a similar issue where using multithreading with similarily frequent calls to the JSON input function result in the following error occuring repeatedly inside the output log. File "C:\Users\User\Documents\Unreal Projects\IAF\IAF\Plugins\tensorflow-ue4\Content\Scripts\TensorFlowComponent.py", line 116, in json_input_blocking The engine crashes after a while and the crash log lists python36, kernel32 and ntdll. Can also see that the memory gets gradually filled over time while it's running, until the eventual crash. Turning multithreading off removes the errors and doesn't result in a crash, and the memory doesn't get filled either. Assuming that this is a similar problem to the original, wouldn't this indicate that the problem is a memory leak? |
With multi-threading on each call to Json input gets handled by a different thread. What's likely happening is a second thread tries to touch the same data before the first one is done with it and it unravels the memory by accessing out of bounds data (despite GIL or in the TF layer), then the continued calls keep leaking (it should have crashed earlier). Probably the best way forward would be to figure out how to add a lock so that JSON inputs get queued one at a time, not starting a new input until last one is fully done. Optionally a single JSON input thread would be the more efficient solution (with internal event queue), but I'm unsure if I know how to properly do that atm. Thanks for providing more examples of the bug, it does narrow down the potential source. |
I have encountered the same problem. I requested json input event every tick as well. I got a different error when I turned off the multithreading: LogPython: Error: Variable pi/dense/kernel already exists, disallowed. Did you mean to set reuse=True or reuse=tf.AUTO_REUSE in VarScope? Originally defined at: I have seen this PyUObject is in invalid state error has been mentioned in the original repository. I don't really understand it. I'll post the link below. https://github.com/20tab/UnrealEnginePython/blob/master/docs/MemoryManagement.md |
I have fixed the error when I turned off multithreading. It works when I turned it off. |
If i call the JSON input function around once every second, its crashing the game with a large python log.
This happens on the CPU version of the plugin but I don't call any tensorflow commands so i doubt that would be causing it.
My JSON input function doesn't do anything for now, just returns an empty quote.
This crash doesn't occur with multi threading off.
Attached the crash logs.
ShooterAIProject-backup-2019.04.15-14.17.37.log
The text was updated successfully, but these errors were encountered: