0
votes

I am trying to train an object detection model with model_main.py file. I can train this on ubuntu environment without any problem, but now moved to win 10 (because I have in that PC a GeForece 1080Ti) and now I have trouble. Training can start and does pretty well until the first checkpoint where I get these errors (also I can restart and it continous training from last checkpoint, but fails again after saving the next...):

so running this command from ...\models-master\research\object_detection folder

python model_main.py --model_dir=training --pipeline_config_path=training/faster_rcnn_inception_v2_pets.config -–num_train_steps=20000 --sample_1_of_n_eval_examples=2 --alsologtostderr

produces this:

INFO:tensorflow:Saving checkpoints for 46040 into training\model.ckpt. I0307 10:01:21.055022 8112 basic_session_run_hooks.py:606] Saving checkpoints for 46040 into training\model.ckpt. WARNING:tensorflow:From C:\Users\Zsetszko21\Anaconda3\envs\tf_env_Ti\lib\site-packages\tensorflow\python\training\saver.py:960: remove_checkpoint (from tensorflow.python.training.checkpoint_management) is deprecated and will be removed in a future version. Instructions for updating: Use standard file APIs to delete files with this prefix. W0307 10:01:22.363223 8112 deprecation.py:323] From C:\Users\Zsetszko21\Anaconda3\envs\tf_env_Ti\lib\site-packages\tensorflow\python\training\saver.py:960: remove_checkpoint (from tensorflow.python.training.checkpoint_management) is deprecated and will be removed in a future version. Instructions for updating: Use standard file APIs to delete files with this prefix. Windows fatal exception: access violation

Thread 0x000023b4 (most recent call first): File "C:\Users\Zsetszko21\Anaconda3\envs\tf_env_Ti\lib\threading.py", line 296 in wait File "C:\Users\Zsetszko21\Anaconda3\envs\tf_env_Ti\lib\queue.py", line 170 in get File "C:\Users\Zsetszko21\Anaconda3\envs\tf_env_Ti\lib\site-packages\tensorflow\python\summary\writer\event_file_writer.py", line 159 in run File "C:\Users\Zsetszko21\Anaconda3\envs\tf_env_Ti\lib\threading.py", line 926 in _bootstrap_inner File "C:\Users\Zsetszko21\Anaconda3\envs\tf_env_Ti\lib\threading.py", line 890 in _bootstrap

Current thread 0x00001fb0 (most recent call first): File "C:\Users\Zsetszko21\Anaconda3\envs\tf_env_Ti\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 84 in _preread_check File "C:\Users\Zsetszko21\Anaconda3\envs\tf_env_Ti\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 122 in read File "C:\Users\Zsetszko21\Anaconda3\envs\tf_env_Ti\lib\site-packages\object_detection-0.1-py3.7.egg\object_detection\utils\label_map_util.py", line 139 in load_labelmap File "C:\Users\Zsetszko21\Anaconda3\envs\tf_env_Ti\lib\site-packages\object_detection-0.1-py3.7.egg\object_detection\utils\label_map_util.py", line 172 in get_label_map_dict File "C:\Users\Zsetszko21\Anaconda3\envs\tf_env_Ti\lib\site-packages\object_detection-0.1-py3.7.egg\object_detection\data_decoders\tf_example_decoder.py", line 64 in init File "C:\Users\Zsetszko21\Anaconda3\envs\tf_env_Ti\lib\site-packages\object_detection-0.1-py3.7.egg\object_detection\data_decoders\tf_example_decoder.py", line 319 in init File "C:\Users\Zsetszko21\Anaconda3\envs\tf_env_Ti\lib\site-packages\object_detection-0.1-py3.7.egg\object_detection\builders\dataset_builder.py", line 130 in build File "C:\Users\Zsetszko21\Anaconda3\envs\tf_env_Ti\lib\site-packages\object_detection-0.1-py3.7.egg\object_detection\inputs.py", line 725 in eval_input File "C:\Users\Zsetszko21\Anaconda3\envs\tf_env_Ti\lib\site-packages\object_detection-0.1-py3.7.egg\object_detection\inputs.py", line 625 in _eval_input_fn File "C:\Users\Zsetszko21\Anaconda3\envs\tf_env_Ti\lib\site-packages\tensorflow_estimator\python\estimator\estimator.py", line 1113 in _call_input_fn File "C:\Users\Zsetszko21\Anaconda3\envs\tf_env_Ti\lib\site-packages\tensorflow_estimator\python\estimator\estimator.py", line 1022 in _get_features_and_labels_from_input_fn File "C:\Users\Zsetszko21\Anaconda3\envs\tf_env_Ti\lib\site-packages\tensorflow_estimator\python\estimator\estimator.py", line 1534 in _call_model_fn_eval File "C:\Users\Zsetszko21\Anaconda3\envs\tf_env_Ti\lib\site-packages\tensorflow_estimator\python\estimator\estimator.py", line 1501 in _evaluate_build_graph File "C:\Users\Zsetszko21\Anaconda3\envs\tf_env_Ti\lib\site-packages\tensorflow_estimator\python\estimator\estimator.py", line 501 in _evaluate File "C:\Users\Zsetszko21\Anaconda3\envs\tf_env_Ti\lib\site-packages\tensorflow_estimator\python\estimator\estimator.py", line 519 in _actual_eval File "C:\Users\Zsetszko21\Anaconda3\envs\tf_env_Ti\lib\site-packages\tensorflow_estimator\python\estimator\estimator.py", line 477 in evaluate File "C:\Users\Zsetszko21\Anaconda3\envs\tf_env_Ti\lib\site-packages\tensorflow_estimator\python\estimator\training.py", line 920 in evaluate_and_export File "C:\Users\Zsetszko21\Anaconda3\envs\tf_env_Ti\lib\site-packages\tensorflow_estimator\python\estimator\training.py", line 539 in _evaluate File "C:\Users\Zsetszko21\Anaconda3\envs\tf_env_Ti\lib\site-packages\tensorflow_estimator\python\estimator\training.py", line 519 in after_save File "C:\Users\Zsetszko21\Anaconda3\envs\tf_env_Ti\lib\site-packages\tensorflow\python\training\basic_session_run_hooks.py", line 619 in _save File "C:\Users\Zsetszko21\Anaconda3\envs\tf_env_Ti\lib\site-packages\tensorflow\python\training\basic_session_run_hooks.py", line 594 in after_run File "C:\Users\Zsetszko21\Anaconda3\envs\tf_env_Ti\lib\site-packages\tensorflow\python\training\monitored_session.py", line 1419 in run File "C:\Users\Zsetszko21\Anaconda3\envs\tf_env_Ti\lib\site-packages\tensorflow\python\training\monitored_session.py", line 1338 in run File "C:\Users\Zsetszko21\Anaconda3\envs\tf_env_Ti\lib\site-packages\tensorflow\python\training\monitored_session.py", line 1252 in run File "C:\Users\Zsetszko21\Anaconda3\envs\tf_env_Ti\lib\site-packages\tensorflow\python\training\monitored_session.py", line 754 in run File "C:\Users\Zsetszko21\Anaconda3\envs\tf_env_Ti\lib\site-packages\tensorflow_estimator\python\estimator\estimator.py", line 1484 in _train_with_estimator_spec File "C:\Users\Zsetszko21\Anaconda3\envs\tf_env_Ti\lib\site-packages\tensorflow_estimator\python\estimator\estimator.py", line 1192 in _train_model_default File "C:\Users\Zsetszko21\Anaconda3\envs\tf_env_Ti\lib\site-packages\tensorflow_estimator\python\estimator\estimator.py", line 1158 in _train_model File "C:\Users\Zsetszko21\Anaconda3\envs\tf_env_Ti\lib\site-packages\tensorflow_estimator\python\estimator\estimator.py", line 367 in train File "C:\Users\Zsetszko21\Anaconda3\envs\tf_env_Ti\lib\site-packages\tensorflow_estimator\python\estimator\training.py", line 714 in run_local File "C:\Users\Zsetszko21\Anaconda3\envs\tf_env_Ti\lib\site-packages\tensorflow_estimator\python\estimator\training.py", line 613 in run File "C:\Users\Zsetszko21\Anaconda3\envs\tf_env_Ti\lib\site-packages\tensorflow_estimator\python\estimator\training.py", line 473 in train_and_evaluate File "model_main.py", line 109 in main File "C:\Users\Zsetszko21\Anaconda3\envs\tf_env_Ti\lib\site-packages\absl\app.py", line 250 in _run_main File "C:\Users\Zsetszko21\Anaconda3\envs\tf_env_Ti\lib\site-packages\absl\app.py", line 299 in run File "C:\Users\Zsetszko21\Anaconda3\envs\tf_env_Ti\lib\site-packages\tensorflow\python\platform\app.py", line 40 in run File "model_main.py", line 113 in (tf_env_Ti) PS A:\PPEVision\trainer\models-master\research\object_detection>

My config file:

# Faster R-CNN with Inception v2, configured for Oxford-IIIT Pets Dataset.
# Users should configure the fine_tune_checkpoint field in the train config as
# well as the label_map_path and input_path fields in the train_input_reader and
# eval_input_reader. Search for "PATH_TO_BE_CONFIGURED" to find the fields that
# should be configured.

model {
  faster_rcnn {
    num_classes: 2
    image_resizer {
      keep_aspect_ratio_resizer {
        min_dimension: 600
        max_dimension: 1024
      }
    }
    feature_extractor {
      type: 'faster_rcnn_inception_v2'
      first_stage_features_stride: 16
    }
    first_stage_anchor_generator {
      grid_anchor_generator {
        scales: [0.25, 0.5, 1.0, 2.0]
        aspect_ratios: [0.5, 1.0, 2.0]
        height_stride: 16
        width_stride: 16
      }
    }
    first_stage_box_predictor_conv_hyperparams {
      op: CONV
      regularizer {
        l2_regularizer {
          weight: 0.0
        }
      }
      initializer {
        truncated_normal_initializer {
          stddev: 0.01
        }
      }
    }
    first_stage_nms_score_threshold: 0.0
    first_stage_nms_iou_threshold: 0.7
    first_stage_max_proposals: 300
    first_stage_localization_loss_weight: 2.0
    first_stage_objectness_loss_weight: 1.0
    initial_crop_size: 14
    maxpool_kernel_size: 2
    maxpool_stride: 2
    second_stage_box_predictor {
      mask_rcnn_box_predictor {
        use_dropout: true
        dropout_keep_probability: 0.95
        fc_hyperparams {
          op: FC
          regularizer {
            l2_regularizer {
              weight: 0.0
            }
          }
          initializer {
            variance_scaling_initializer {
              factor: 1.0
              uniform: true
              mode: FAN_AVG
            }
          }
        }
      }
    }
    second_stage_post_processing {
      batch_non_max_suppression {
        score_threshold: 0.0
        iou_threshold: 0.6
        max_detections_per_class: 100
        max_total_detections: 300
      }
      score_converter: SOFTMAX
    }
    second_stage_localization_loss_weight: 2.0
    second_stage_classification_loss_weight: 1.0
  }
}

train_config: {
  batch_size: 1
  optimizer {
    momentum_optimizer: {
      learning_rate: {
          exponential_decay_learning_rate {
          initial_learning_rate: 0.00200000018999
          decay_steps: 1000
          decay_factor: 0.989999988079
        }
        #manual_step_learning_rate {
        #  initial_learning_rate: 0.0002
        #  schedule {
        #    step: 100000
        #    learning_rate: .002
        #  }

        #}

      }
      momentum_optimizer_value: 0.9
    }
    use_moving_average: false
  }
  gradient_clipping_by_norm: 10.0
  fine_tune_checkpoint:  "A:\\PPEVision\\trainer\\models-master\\research\\object_detection\\faster_rcnn_inception_v2_coco_2018_01_28\\model.ckpt"
  from_detection_checkpoint: true
  load_all_detection_checkpoint_vars: true
  # Note: The below line limits the training process to 200K steps, which we
  # empirically found to be sufficient enough to train the pets dataset. This
  # effectively bypasses the learning rate schedule (the learning rate will
  # never decay). Remove the below line to train indefinitely.
  num_steps: 200000
  data_augmentation_options {
    random_horizontal_flip {
    }
  }
}


train_input_reader: {
  tf_record_input_reader {
    input_path: "A:\\PPEVision\\trainer\\models-master\\research\\object_detection\\train.record"
  }
  label_map_path: "A:\\PPEVision\\trainer\\models-master\\research\\object_detection\\training\\labelmap.pbtxt"
}

eval_config: {
  metrics_set: "coco_detection_metrics"
  num_examples: 1000
  num_visualizations: 1000
  visualization_export_dir: "A:\\PPEVision\\trainer\\models-master\\research\\object_detection\\eval"
  eval_interval_secs: 120
}

eval_input_reader: {
  tf_record_input_reader {
    input_path: "A:\\PPEVision\\trainer\\models-master\\research\\object_detection\\test.record"
  }
  label_map_path: "A:\\PPEVision\\trainer\\models-master\\research\\object_detection\\labelmap.pbtxt"
  shuffle: true
  num_readers: 1
}

I also added these lines to prevent any OOM to model_main.py:

  session_config = tf.ConfigProto()
  session_config.gpu_options.per_process_gpu_memory_fraction = 0.7    # replace this field with whichever real number you prefer
                                                                    # also gives a workaround to specify RAM usage
  config = tf.estimator.RunConfig(model_dir=FLAGS.model_dir, session_config=session_config)

My specs:

Win10 Geforce GTX 1080Ti 11Gb 32Gb RAM i5-7500 3Ghz CPU Tensorflow 1.14-gpu created with conda env +-----------------------------------------------------------------------------+ | NVIDIA-SMI 442.50 Driver Version: 442.50 CUDA Version: 10.2 | |-------------------------------+----------------------+----------------------+ | GPU Name TCC/WDDM | Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. | |===============================+======================+======================| | 0 GeForce GTX 108... WDDM | 00000000:01:00.0 On | N/A | | 23% 36C P8 13W / 250W | 449MiB / 11264MiB | 0% Default | +-------------------------------+----------------------+----------------------+

1

1 Answers

0
votes

I had similar issues and it appears that instead of label_map.pbtxt, I had to replace it with label_map.pbtxt.txt. Also, maybe replace \ by /.