models icon indicating copy to clipboard operation
models copied to clipboard

Can't train the decoder of the perspective Transformer

Open mees opened this issue 9 years ago • 6 comments

System information

  • What is the top-level directory of the model you are using: Ptn directory
  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow): No
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Ubuntu 14.04
  • TensorFlow installed from (source or binary): Source
  • TensorFlow version (use command below): ('v1.3.0-rc1-27-g2784b1c', '1.3.0-rc2')
  • Bazel version (if compiling from source): 0.5.2
  • CUDA/cuDNN version: 8.0/5.1
  • GPU model and memory: Titan X
  • Exact command to reproduce: run -c opt :train_ptn -- --init_model='/home/meeso/models/ptn/my_models/deeprotator_pretrain/train/' --checkpoint_dir='/home/meeso/models/ptn/my_models/' --inp_dir='/home/meeso/Datasets/shapenet_tf/

Describe the problem

When I try to run the command for training the volumetric decoder, it breaks after one iteration.

Source code / logs

`2017-08-08 17:45:24.214032: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1045] Creating TensorFlow device (/gpu:0) -> (device: 0, name: TITAN X (Pascal), pci bus id: 0000:02:00.0) 2017-08-08 17:45:24.214042: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1045] Creating TensorFlow device (/gpu:1) -> (device: 1, name: TITAN X (Pascal), pci bus id: 0000:03:00.0) 2017-08-08 17:45:24.214049: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1045] Creating TensorFlow device (/gpu:2) -> (device: 2, name: TITAN X (Pascal), pci bus id: 0000:81:00.0) 2017-08-08 17:45:24.214056: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1045] Creating TensorFlow device (/gpu:3) -> (device: 3, name: TITAN X (Pascal), pci bus id: 0000:82:00.0) 2017-08-08 17:45:40.764281: W tensorflow/core/framework/op_kernel.cc:1192] Unknown: exceptions.RuntimeError: main thread is not in main loop Traceback (most recent call last): File "/home/meeso/.cache/bazel/_bazel_meeso/3a6bfcc5e3fa6521c178dee287de79bc/execroot/main/bazel-out/local-opt/bin/train_ptn.runfiles/main/train_ptn.py", line 230, in app.run() File "/home/meeso/.virtualenvs/2d_to_3d/local/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 48, in run _sys.exit(main(_sys.argv[:1] + flags_passthrough)) File "/home/meeso/.cache/bazel/_bazel_meeso/3a6bfcc5e3fa6521c178dee287de79bc/execroot/main/bazel-out/local-opt/bin/train_ptn.runfiles/main/train_ptn.py", line 226, in main save_interval_secs=FLAGS.save_interval_secs) File "/home/meeso/.virtualenvs/2d_to_3d/local/lib/python2.7/site-packages/tensorflow/contrib/slim/python/slim/learning.py", line 755, in train sess, train_op, global_step, train_step_kwargs) File "/home/meeso/.virtualenvs/2d_to_3d/local/lib/python2.7/site-packages/tensorflow/contrib/slim/python/slim/learning.py", line 488, in train_step run_metadata=run_metadata) File "/home/meeso/.virtualenvs/2d_to_3d/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 895, in run run_metadata_ptr) File "/home/meeso/.virtualenvs/2d_to_3d/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1124, in _run feed_dict_tensor, options, run_metadata) File "/home/meeso/.virtualenvs/2d_to_3d/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1321, in _do_run options, run_metadata) File "/home/meeso/.virtualenvs/2d_to_3d/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1340, in _do_call raise type(e)(node_def, op, message) tensorflow.python.framework.errors_impl.UnknownError: exceptions.RuntimeError: main thread is not in main loop [[Node: PyFunc = PyFunc[Tin=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_INT64, DT_FLOAT, DT_FLOAT], Tout=[DT_UINT8], token="pyfunc_0", _device="/job:localhost/replica:0/task:0/cpu:0"](mul_3, ResizeNearestNeighbor, ResizeNearestNeighbor_1, global_step/read, data_loading_shapenet_chair/val/batching_queues/shapenet_chair/val:1, decoder_1/Conv3d_transpose_2/Sigmoid/_4311)]] [[Node: PyFunc/_9028 = _Recvclient_terminated=false, recv_device="/job:localhost/replica:0/task:0/gpu:0", send_device="/job:localhost/replica:0/task:0/cpu:0", send_device_incarnation=1, tensor_name="edge_32788_PyFunc", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/gpu:0"]]

Caused by op u'PyFunc', defined at: File "/home/meeso/.cache/bazel/_bazel_meeso/3a6bfcc5e3fa6521c178dee287de79bc/execroot/main/bazel-out/local-opt/bin/train_ptn.runfiles/main/train_ptn.py", line 230, in app.run() File "/home/meeso/.virtualenvs/2d_to_3d/local/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 48, in run _sys.exit(main(_sys.argv[:1] + flags_passthrough)) File "/home/meeso/.cache/bazel/_bazel_meeso/3a6bfcc5e3fa6521c178dee287de79bc/execroot/main/bazel-out/local-opt/bin/train_ptn.runfiles/main/train_ptn.py", line 202, in main output_voxels=val_outputs['voxels_1']) File "/home/meeso/models/ptn/model_ptn.py", line 141, in write_disk_grid ], [tf.uint8], 'write_grid')[0] File "/home/meeso/.virtualenvs/2d_to_3d/local/lib/python2.7/site-packages/tensorflow/python/ops/script_ops.py", line 203, in py_func input=inp, token=token, Tout=Tout, name=name) File "/home/meeso/.virtualenvs/2d_to_3d/local/lib/python2.7/site-packages/tensorflow/python/ops/gen_script_ops.py", line 36, in _py_func name=name) File "/home/meeso/.virtualenvs/2d_to_3d/local/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 767, in apply_op op_def=op_def) File "/home/meeso/.virtualenvs/2d_to_3d/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2630, in create_op original_op=self._default_original_op, op_def=op_def) File "/home/meeso/.virtualenvs/2d_to_3d/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1204, in init self._traceback = self._graph._extract_stack() # pylint: disable=protected-access

UnknownError (see above for traceback): exceptions.RuntimeError: main thread is not in main loop [[Node: PyFunc = PyFunc[Tin=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_INT64, DT_FLOAT, DT_FLOAT], Tout=[DT_UINT8], token="pyfunc_0", _device="/job:localhost/replica:0/task:0/cpu:0"](mul_3, ResizeNearestNeighbor, ResizeNearestNeighbor_1, global_step/read, data_loading_shapenet_chair/val/batching_queues/shapenet_chair/val:1, decoder_1/Conv3d_transpose_2/Sigmoid/_4311)]] [[Node: PyFunc/_9028 = _Recvclient_terminated=false, recv_device="/job:localhost/replica:0/task:0/gpu:0", send_device="/job:localhost/replica:0/task:0/cpu:0", send_device_incarnation=1, tensor_name="edge_32788_PyFunc", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/gpu:0"]]

Exception RuntimeError: RuntimeError('main thread is not in main loop',) in <bound method PhotoImage.del of <Tkinter.PhotoImage instance at 0x7f623863a170>> ignored Tcl_AsyncDelete: async handler deleted by the wrong thread`

mees avatar Aug 08 '17 15:08 mees

@xcyan, it creates the image 0.jpg before breaking. I have all dependencies and don't know where the problem is.

mees avatar Aug 08 '17 15:08 mees

Looking at the error message, this might be related: https://stackoverflow.com/questions/30816275/how-to-thread-matplotlib-in-python

You are running multigpu training with Tensorflow 1.3 under ubuntu. However, I think we haven't tested with this combination. @arkanath

Two solutions: (1) switch to tf1.2 or tf1.1 (2) turn off the visualization part by commenting out the write_disk_grid() and adding return None at the end. Commenting out matplotlib in Utils.py

xcyan avatar Aug 08 '17 21:08 xcyan

I am not passing any arguments for multi-gpu, so that's not the issue. To make sure, I have just masked the GPUs, so that only one is visible for tensorflow with

import os
os.environ["CUDA_DEVICE_ORDER"]="PCI_BUS_ID"  
os.environ["CUDA_VISIBLE_DEVICES"]="1"

And I still get the same error.

mees avatar Aug 09 '17 09:08 mees

Okey so I have found a solution. The code doesn't work with tf 1.2, because it relies of tf.contrib.slim.summaries that was introduced in 1.3, running the code with tf 1.2 gives you AttributeError: 'module' object has no attribute 'add_scalar_summary'. However, the core issue was the matplotlib multithreading. I fixed the issue by using the Agg backend. I will send a pull request. @xcyan @arkanath

mees avatar Aug 09 '17 13:08 mees

Yes the readme states that you have to run the code with the latest tensorflow from source.

On Wed, Aug 9, 2017 at 11:56 PM, Oier Mees [email protected] wrote:

Okey so I have found a solution. The code doesn't work with tf 1.2, because it relies of tf.contrib.slim.summaries that was introduced in 1.3, running the code with tf 1.2 gives you AttributeError: 'module' object has no attribute 'add_scalar_summary'. However, the core issue was the matplotlib multithreading. I fixed the issue by using the Agg backend. I will send a pull request. @xcyan https://github.com/xcyan @arkanath https://github.com/arkanath

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tensorflow/models/issues/2160#issuecomment-321262480, or mute the thread https://github.com/notifications/unsubscribe-auth/ACpELPtBvztxOob1Fndfq54vEaModiA_ks5sWbqMgaJpZM4Ow70P .

-- Arkanath Pathak http://arkanath.com

arkanath avatar Aug 09 '17 23:08 arkanath

@arkanath I can train the rotator successfully,but I can not train the PTN, the loss can not drop to low, and the images which be show in tensorboard is terrible. I install the tensorflow from conda,(not from source may problem?) could you give me some ideas? Thank you very much. I have been got stuck.

ZYCZH avatar Jan 15 '19 13:01 ZYCZH