ColinKohler / BulletArm

BulletArm is a benchmark and learning-environment for robotic manipulation.
MIT License
69 stars 18 forks source link

tkinter error #3

Closed hmhuy0 closed 2 years ago

hmhuy0 commented 2 years ago

Hi, I usually get Tkinter problems as below when training. After this happened, I had to reboot my device to free GPU memory cause I could not find the process in the GPU processes table to kill.

100%|████████████████████████████████████████████████| 100/100 [01:16<00:00, 1.31it/s] Action Step:4015; Episode: 992.0; Reward:0.520; Eval Reward:0.000; Explore:0.01; Loss:0Exception ignored in: <function Image.__del__ at 0x7f01fad40440>00:03<00:41, 2.36it/s] Traceback (most recent call last): File "/home/huy/anaconda3/envs/bullet-arm/lib/python3.7/tkinter/__init__.py", line 3507, in __del__ self.tk.call('image', 'delete', self.name) RuntimeError: main thread is not in main loop Action Step:4045; Episode: 1000.0; Reward:0.480; Eval Reward:0.000; Explore:0.01; LossException ignored in: <function Variable.__del__ at 0x7f01fad239e0>:12<01:14, 1.19it/s] Traceback (most recent call last): File "/home/huy/anaconda3/envs/bullet-arm/lib/python3.7/tkinter/__init__.py", line 332, in __del__ if self._tk.getboolean(self._tk.call("info", "exists", self._name)): RuntimeError: main thread is not in main loop Action Step:4050; Episode: 1001.0; Reward:0.470; Eval Reward:0.000; Explore:0.01; Loss:Exception ignored in: <function Variable.__del__ at 0x7f01fad239e0> Traceback (most recent call last): File "/home/huy/anaconda3/envs/bullet-arm/lib/python3.7/tkinter/__init__.py", line 332, in __del__ if self._tk.getboolean(self._tk.call("info", "exists", self._name)): RuntimeError: main thread is not in main loop Action Step:4055; Episode: 1001.0; Reward:0.470; Eval Reward:0.000; Explore:0.01; LossException ignored in: <function Variable.__del__ at 0x7f01fad239e0>:14<01:40, 1.15s/it] Traceback (most recent call last): File "/home/huy/anaconda3/envs/bullet-arm/lib/python3.7/tkinter/__init__.py", line 332, in __del__ if self._tk.getboolean(self._tk.call("info", "exists", self._name)): RuntimeError: main thread is not in main loop Action Step:4060; Episode: 1001.0; Reward:0.470; Eval Reward:0.000; Explore:0.01; Loss:Exception ignored in: <function Variable.__del__ at 0x7f01fad239e0> Traceback (most recent call last): File "/home/huy/anaconda3/envs/bullet-arm/lib/python3.7/tkinter/__init__.py", line 332, in __del__ if self._tk.getboolean(self._tk.call("info", "exists", self._name)): RuntimeError: main thread is not in main loop Action Step:4070; Episode: 1005.0; Reward:0.450; Eval Reward:0.000; Explore:0.01; Loss:Exception ignored in: <function Image.__del__ at 0x7f01fad40440>00:15<01:26, 1.01s/it] Traceback (most recent call last): File "/home/huy/anaconda3/envs/bullet-arm/lib/python3.7/tkinter/__init__.py", line 3507, in __del__ self.tk.call('image', 'delete', self.name) RuntimeError: main thread is not in main loop Action Step:4100; Episode: 1010.0; Reward:0.410; Eval Reward:0.000; Explore:0.01; LossException ignored in: <function Variable.__del__ at 0x7f01fad239e0>:25<01:22, 1.07s/it] Traceback (most recent call last): File "/home/huy/anaconda3/envs/bullet-arm/lib/python3.7/tkinter/__init__.py", line 332, in __del__ if self._tk.getboolean(self._tk.call("info", "exists", self._name)): RuntimeError: main thread is not in main loop Action Step:4105; Episode: 1011.0; Reward:0.410; Eval Reward:0.000; Explore:0.01; LossException ignored in: <function Variable.__del__ at 0x7f01fad239e0>:26<01:17, 1.02s/it] Traceback (most recent call last): File "/home/huy/anaconda3/envs/bullet-arm/lib/python3.7/tkinter/__init__.py", line 332, in __del__ if self._tk.getboolean(self._tk.call("info", "exists", self._name)): RuntimeError: main thread is not in main loop Action Step:4110; Episode: 1011.0; Reward:0.410; Eval Reward:0.000; Explore:0.01; Loss:Exception ignored in: <function Variable.__del__ at 0x7f01fad239e0> Traceback (most recent call last): File "/home/huy/anaconda3/envs/bullet-arm/lib/python3.7/tkinter/__init__.py", line 332, in __del__ if self._tk.getboolean(self._tk.call("info", "exists", self._name)): RuntimeError: main thread is not in main loop Action Step:4115; Episode: 1012.0; Reward:0.410; Eval Reward:0.000; Explore:0.01; Loss:Exception ignored in: <function Variable.__del__ at 0x7f01fad239e0>27<01:20, 1.07s/it] Traceback (most recent call last): File "/home/huy/anaconda3/envs/bullet-arm/lib/python3.7/tkinter/__init__.py", line 332, in __del__ if self._tk.getboolean(self._tk.call("info", "exists", self._name)): RuntimeError: main thread is not in main loop Action Step:4120; Episode: 1012.0; Reward:0.410; Eval Reward:0.000; Explore:0.01; Loss:./run.sh: line 4: 70195 Aborted (core dumped) python bulletarm_baselines/fc_dqn/scripts/main_goal.py --algorithm=dqn --architecture=equi_asr --env=block_stacking --fill_buffer_deconstruct --planner_episode=5

ColinKohler commented 2 years ago

Could you try to add these two lines to the top of fc_dqn/utils/logger.py import matplotlib matplotlib.use('Agg') This should force matplotlib to use a non-GUI backend for plotting.

Out of curiosity are you running this over ssh?

hmhuy0 commented 2 years ago

Could you try to add these two lines to the top of fc_dqn/utils/logger.py import matplotlib matplotlib.use('Agg') This should force matplotlib to use a non-GUI backend for plotting.

Out of curiosity are you running this over ssh?

Thank you for your reply. The error still occurs after adding your lines. and no, I'm running code in local.

ColinKohler commented 2 years ago

Sorry for not being able to test this myself but I do think this should fix this problem provided we put it in the correct place. Could you please try to put those same two lines at the top of fc_sqn/scripts/main.py.

Essentially, we need to turn off the matplotlib GUI before pyplot gets imported for the first time which I believe is in main.py.

hmhuy0 commented 2 years ago

Thank you, the problem is solved.

pointW commented 2 years ago

Ran into the same problem today.

Essentially, we need to turn off the matplotlib GUI before pyplot gets imported for the first time which I believe is in main.py.

It is correct that matplotlib.use('Agg') needs to be called at the top of the main function. Commits 7db824cec1886badc3c68fc6cc21995e8226c14b and c3d4cbeb6d075a3b958d29a83238793981c84fe3 should have fixed the problem in both the open loop and the close loop baselines.