models icon indicating copy to clipboard operation
models copied to clipboard

UnboundLocalError: local variable 'total_loss' referenced before assignment

Open liangxiao05 opened this issue 8 years ago • 5 comments

I download the lastest codes 'tensorflow/models' to test the ssd_mobinetv2 model today. But when training I met the problem ,It never occurs before when I used the codes which were released about 2 months ago .

system summary ubuntu 16.04: 32 GB RAM GPU : GeForce Titan XP *2 cuda : 9.0 cudnn: 7.1 tensorflow-gpu: 1.5.0 python: 2.7

error log Here is the error log

python object_detection/train.py --logtostderr --train_dir='/home/eco/tr ain_1.0_eco_ssdlite_v2' --pipeline_config_path='/home/eco/train_1.0_eco_ssdlite_v2/ssd_mobilenet_v2.config' /usr/local/lib/python2.7/dist-packages/h5py/init.py:36: FutureWarning: Conversion of the second argument of issubdtype from float to np.floating is deprecated. In future, it will be treated as np.float64 == np.dtype(float).type. from ._conv import register_converters as _register_converters WARNING:tensorflow:From /home/eco/tensorflow/models/research/object_detection/trainer.py:228: create_global_step (from tensorflow.contrib.framework.python.ops.variables) is deprecated and will be removed in a future version. Instructions for updating: Please switch to tf.train.create_global_step INFO:tensorflow:depth of additional conv before box predictor: 0 INFO:tensorflow:depth of additional conv before box predictor: 0 INFO:tensorflow:depth of additional conv before box predictor: 0 INFO:tensorflow:depth of additional conv before box predictor: 0 INFO:tensorflow:depth of additional conv before box predictor: 0 INFO:tensorflow:depth of additional conv before box predictor: 0 INFO:tensorflow:Summary name /clone_loss is illegal; using clone_loss instead. WARNING:tensorflow:From /usr/local/lib/python2.7/dist-packages/tensorflow/contrib/slim/python/slim/learning.py:736: init (from tensorflow.python.training.supervisor) is deprecated and will be removed in a future version. Instructions for updating: Please switch to tf.train.MonitoredTrainingSession 2018-03-24 12:21:01.119649: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA 2018-03-24 12:21:01.407238: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1105] Found device 0 with properties: name: TITAN Xp major: 6 minor: 1 memoryClockRate(GHz): 1.582 pciBusID: 0000:05:00.0 totalMemory: 11.90GiB freeMemory: 11.21GiB 2018-03-24 12:21:01.594617: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1105] Found device 1 with properties: name: TITAN Xp major: 6 minor: 1 memoryClockRate(GHz): 1.582 pciBusID: 0000:09:00.0 totalMemory: 11.90GiB freeMemory: 11.74GiB 2018-03-24 12:21:01.595355: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1120] Device peer to peer matrix 2018-03-24 12:21:01.595392: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1126] DMA: 0 1 2018-03-24 12:21:01.595399: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1136] 0: Y Y 2018-03-24 12:21:01.595404: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1136] 1: Y Y 2018-03-24 12:21:01.595413: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1195] Creating TensorFlow device (/device:GPU:0) -> (device: 0, name: TITAN Xp, pci bus id: 0000:05:00.0, compute capability: 6.1) 2018-03-24 12:21:01.595420: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1195] Creating TensorFlow device (/device:GPU:1) -> (device: 1, name: TITAN Xp, pci bus id: 0000:09:00.0, compute capability: 6.1) INFO:tensorflow:Starting Session. INFO:tensorflow:Saving checkpoint to path /home/eco/train_1.0_eco_ssdlite_v2/model.ckpt INFO:tensorflow:Starting Queues. INFO:tensorflow:global_step/sec: 0 INFO:tensorflow:Caught OutOfRangeError. Stopping Training. INFO:tensorflow:Finished training! Saving model to disk. Traceback (most recent call last): File "object_detection/train.py", line 167, in tf.app.run() File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py", line 124, in run _sys.exit(main(argv)) File "object_detection/train.py", line 163, in main worker_job_name, is_chief, FLAGS.train_dir) File "/home/eco/tensorflow/models/research/object_detection/trainer.py", line 370, in train saver=saver) File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/slim/python/slim/learning.py", line 790, in train return total_loss UnboundLocalError: local variable 'total_loss' referenced before assignment

liangxiao05 avatar Mar 24 '18 04:03 liangxiao05

I think in your .config about path incorrect.

Apirom avatar Mar 24 '18 12:03 Apirom

@Apirom e.....sorry,you are right the input_path is indeed incorrect in the .config ,and the prompt messages are different from before. thanks!

liangxiao05 avatar Mar 24 '18 14:03 liangxiao05

I have the same issue with python 3.5 on cpu

jennyabr avatar Mar 25 '18 13:03 jennyabr

Hi,

I got the same issue with Python 3.6 with the tensorflow_gpu framework(Ver 1.5). It seems that be related to "checkpint" path in the pipeline.config file. Could you help teach me how to configure the setting? Thanks.

/======log message INFO:tensorflow:Restoring parameters from object_detection/model/train/model.ckpt-0 41 INFO:tensorflow:Starting Session. 42 INFO:tensorflow:Saving checkpoint to path object_detection/model/train/model.ckpt 43 INFO:tensorflow:Starting Queues. 44 INFO:tensorflow:global_step/sec: 0 45 INFO:tensorflow:Caught OutOfRangeError. Stopping Training. 46 INFO:tensorflow:Finished training! Saving model to disk. 47 Traceback (most recent call last): ======/

samhsieh avatar Apr 02 '18 09:04 samhsieh

another solution to possible cause is you didn't created the test.record and train.record files for creating these,you need to run these two commands

python generate_tfrecord.py --csv_input=images\train_labels.csv --image_dir=images\train --output_path=train.record

python generate_tfrecord.py --csv_input=images\test_labels.csv --image_dir=images\test --output_path=test.record

ZeeDeep avatar Apr 08 '18 22:04 ZeeDeep