lescientifik/open_brats2020

main thread is not in main loop

Opened this issue · 0 comments

I start training the model as the documentation suggests and it suddenly stops at a random point of the training (I have run it several times and it stopped in all of them at different epochs). The error description is as follows:

train Epoch: [12][ 85/295] Time 1.469 ( 1.454) Data 0.007 ( 0.047) Loss 8.0506e-02 (1.8724e-01)
train Epoch: [12][ 86/295] Time 1.452 ( 1.454) Data 0.007 ( 0.047) Loss 1.6553e-01 (1.8699e-01)
train Epoch: [12][ 87/295] Time 1.331 ( 1.452) Data 0.007 ( 0.046) Loss 1.2983e-01 (1.8634e-01)
Exception ignored in: <function Image.del at 0x7fec55482040>
Traceback (most recent call last):
File "/home/user/.conda/envs/brats2020/lib/python3.8/tkinter/init.py", line 4017, in del
self.tk.call('image', 'delete', self.name)
RuntimeError: main thread is not in main loop

I have looked up the error on the internet and it seems to be kind of an incompatibility between tkinter and PySimpleGUI.

https://www.pysimplegui.org/en/latest/#do-not-attempt-to-call-pysimplegui-from-multiple-threads-at-least-the-tkinter-based-port-because-tkinter-is-not-threadsafe-and-has-known-issues-with-multiple-threads : "Be sure and delete your windows after you close them if you are running with multiple threads. There is a chance another thread's garbage collect will attempt to delete the window when not in the mainthread which will cause tkinter to crash."

However, I think we're not using PySimpleGUI, so from what I've read I guess this error is because of multithreading and parallelism, even though this code parallelises through PyTorch library...

Do you have an idea about how to solve this problem?