[object_detection] "RuntimeError: main thread is not in main loop"and"tensorflow.python.framework.errors_impl.ResourceExhaustedError: OOM when allocat ing tensor with shape[64,6426,48] and type float on /job:localhost/replica:0/tas k:0/device:GPU:0 by allocator GPU_0_bfc"
the config file I used is "ssd_resnet50_v1_fpn_shared_box_predictor_640x640_coco14_sync.config", "batch_size" default value is 64. an error occurred at run time
2018-07-17 23:38:53.847260: I T:\src\github\tensorflow\tensorflow\core\common_ru ntime\bfc_allocator.cc:680] Stats: Limit: 3532349440 InUse: 3437157888 MaxInUse: 3531101696 NumAllocs: 6995 MaxAllocSize: 1090912256
2018-07-17 23:38:53.848260: W T:\src\github\tensorflow\tensorflow\core\common_ru ntime\bfc_allocator.cc:279] **************************************************** ***********************************************x Traceback (most recent call last): File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\si te-packages\tensorflow\python\client\session.py", line 1322, in _do_call return fn(*args) File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\si te-packages\tensorflow\python\client\session.py", line 1307, in _run_fn options, feed_dict, fetch_list, target_list, run_metadata) File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\si te-packages\tensorflow\python\client\session.py", line 1409, in _call_tf_session run run_metadata) tensorflow.python.framework.errors_impl.ResourceExhaustedError: OOM when allocat ing tensor with shape[64,6426,48] and type float on /job:localhost/replica:0/tas k:0/device:GPU:0 by allocator GPU_0_bfc [[Node: swap_in_Loss/Loss_1/sub_1_1 = _CopyFromHostToGpu[T=DT_FLOAT, _c lass=["loc@Loss/Loss_1/sub_1_1"], _device="/job:localhost/replica:0/task:0/devic e:GPU:0"](swap_out_Loss/Loss_1/sub_1_1, ^WeightSharedConvolutionalBoxPredictor/C lassPredictor/BiasAdd)]] Hint: If you want to see a list of allocated tensors when OOM happens, add repor t_tensor_allocations_upon_oom to RunOptions for current allocation info.
I don't know why. I felt like there might be not enough memory. I tried to change the value of "batch_size" to a smaller value,but a new error has emerged .
Traceback (most recent call last):
File "object_detection\model_main.py", line 101, in
File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\si te-packages\tensorflow\python\ops\script_ops.py", line 158, in call ret = func(*args)
File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\Lib\si te-packages\tensorflow\models-master\research\object_detection\utils\visualizati on_utils.py", line 693, in cdf_plot fig = plt.figure(frameon=False)
File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\si te-packages\matplotlib\pyplot.py", line 548, in figure **kwargs)
File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\si te-packages\matplotlib\backend_bases.py", line 161, in new_figure_manager return cls.new_figure_manager_given_figure(num, fig)
File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\si te-packages\matplotlib\backends_backend_tk.py", line 1053, in new_figure_manage r_given_figure icon_img = Tk.PhotoImage(file=icon_fname)
File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\tk inter_init_.py", line 3542, in init Image.init(self, 'photo', name, cnf, master, **kw)
File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\tk inter_init_.py", line 3498, in init self.tk.call(('image', 'create', imgtype, name,) + options)
RuntimeError: main thread is not in main loop
[[Node: Loss/PyFunc_1 = PyFunc[Tin=[DT_FLOAT], Tout=[DT_UINT8], token="
pyfunc_1", device="/job:localhost/replica:0/task:0/device:CPU:0"](Loss/Squeeze 1/_5297)]] [[Node: train/update_FeatureExtractor/resnet_v1_50/block4/unit_1/bottle neck_v1/conv1/weights/ApplyMomentum/_8102 = _Recvclient_terminated=false, recv_ device="/job:localhost/replica:0/task:0/device:GPU:0", send_device="/job:localho st/replica:0/task:0/device:CPU:0", send_device_incarnation=1, tensor_name="edge_ 10150...lyMomentum", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/tas k:0/device:GPU:0"]]
Caused by op 'Loss/PyFunc_1', defined at:
File "object_detection\model_main.py", line 101, in
input=inp, token=token, Tout=Tout, name=name)
File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\si te-packages\tensorflow\python\ops\gen_script_ops.py", line 130, in py_func "PyFunc", input=input, token=token, Tout=Tout, name=name) File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\si te-packages\tensorflow\python\framework\op_def_library.py", line 787, in apply op_helper op_def=op_def) File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\si te-packages\tensorflow\python\framework\ops.py", line 3414, in create_op op_def=op_def) File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\si te-packages\tensorflow\python\framework\ops.py", line 1740, in init self._traceback = self._graph._extract_stack() # pylint: disable=protected- access
UnknownError (see above for traceback): RuntimeError: main thread is not in main loop Traceback (most recent call last):
File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\si te-packages\tensorflow\python\ops\script_ops.py", line 158, in call ret = func(*args)
File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\Lib\si te-packages\tensorflow\models-master\research\object_detection\utils\visualizati on_utils.py", line 693, in cdf_plot fig = plt.figure(frameon=False)
File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\si te-packages\matplotlib\pyplot.py", line 548, in figure **kwargs)
File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\si te-packages\matplotlib\backend_bases.py", line 161, in new_figure_manager return cls.new_figure_manager_given_figure(num, fig)
File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\si te-packages\matplotlib\backends_backend_tk.py", line 1053, in new_figure_manage r_given_figure icon_img = Tk.PhotoImage(file=icon_fname)
File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\tk inter_init_.py", line 3542, in init Image.init(self, 'photo', name, cnf, master, **kw)
File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\tk inter_init_.py", line 3498, in init self.tk.call(('image', 'create', imgtype, name,) + options)
RuntimeError: main thread is not in main loop
[[Node: Loss/PyFunc_1 = PyFunc[Tin=[DT_FLOAT], Tout=[DT_UINT8], token="
pyfunc_1", device="/job:localhost/replica:0/task:0/device:CPU:0"](Loss/Squeeze 1/_5297)]] [[Node: train/update_FeatureExtractor/resnet_v1_50/block4/unit_1/bottle neck_v1/conv1/weights/ApplyMomentum/_8102 = _Recvclient_terminated=false, recv_ device="/job:localhost/replica:0/task:0/device:GPU:0", send_device="/job:localho st/replica:0/task:0/device:CPU:0", send_device_incarnation=1, tensor_name="edge_ 10150...lyMomentum", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/tas k:0/device:GPU:0"]]
Error in atexit.run_exitfuncs: Traceback (most recent call last): File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\si te-packages\matplotlib_pylab_helpers.py", line 78, in destroy_all manager.destroy() File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\si te-packages\matplotlib\backends_backend_tk.py", line 558, in destroy self.window.destroy() File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\tk inter_init.py", line 2058, in destroy for c in list(self.children.values()): c.destroy() File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\tk inter_init_.py", line 2302, in destroy self.tk.call('destroy', self._w) RuntimeError: main thread is not in main loop
Try setting the batch size smaller. That usually gets rid of the OOM error. I think its because you are out of memory. The "main thread is not in main loop" error is a similar issue that im having(#4791), let me know if you find a solution for it?
@MonkeyWithAComputer I'm also facing the same problem. I'm using 2 K80 GPU cards to training on my dataset. My dataset consists of 20k images. I tried using a smaller batch size but it still the same.
I'm having the same problem. I'm training on 2 Titan XP. When I set the batch size to a small enough value I get the same RuntimeError.
One line 703 of utils/visualization_utils.py change cdf_plot=tf.py_func(cdf_plot, [values], tf.uint8) to cdf_plot=tf.py_func(cdf_plot, [values], tf.float32)
this will eliminate the errors, or at least it did for me
Hi There, We are checking to see if you still need help on this, as this seems to be considerably old issue. Please update this issue with the latest information, code snippet to reproduce your issue and error you are seeing. If we don't hear from you in the next 7 days, this issue will be closed automatically. If you don't need help on this issue any more, please consider closing this.