models icon indicating copy to clipboard operation
models copied to clipboard

Object detect : Batchsize is 2 and cannot be increased more when use model fasterRcnn_inception_resnet_v2 ?

Open jixiaonanzhuaizhuai opened this issue 8 years ago • 7 comments

When I use model fasterRcnn_inception_resnet_v2 with my own data for training, I set batchsize=2 to use my 1 GPU.

I found that my training loss curve has not been convergent, and the shock is quite severe. Is there any way to help me increase my batchsize

jixiaonanzhuaizhuai avatar Aug 03 '18 07:08 jixiaonanzhuaizhuai

Thank you for your post. We noticed you have not filled out the following field in the issue template. Could you update them if they are relevant in your case, or leave them as N/A? Thanks. What is the top-level directory of the model you are using Have I written custom code OS Platform and Distribution TensorFlow installed from TensorFlow version Bazel version CUDA/cuDNN version GPU model and memory Exact command to reproduce

tensorflowbutler avatar Aug 03 '18 19:08 tensorflowbutler

Which GPU are you running?

The batch size you can train with is dependent on the GPU you're running with (and the amount of ram on the CPU). You might be able to increase the batch size by lower the image resolution on the detector, or by using a different feature extractor.

derekjchow avatar Aug 03 '18 20:08 derekjchow

@derekjchow

+-----------------------------------------------------------------------------+ | NVIDIA-SMI 384.130 Driver Version: 384.130 | |-------------------------------+----------------------+----------------------+ | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. | |===============================+======================+======================| | 0 GeForce GTX 108... Off | 00000000:02:00.0 On | N/A | | 24% 42C P8 18W / 250W | 213MiB / 11170MiB | 16% Default | +-------------------------------+----------------------+----------------------+ | 1 GeForce GTX 108... Off | 00000000:03:00.0 Off | N/A | | 36% 54C P8 19W / 250W | 10786MiB / 11172MiB | 0% Default | +-------------------------------+----------------------+----------------------+ | 2 GeForce GTX 108... Off | 00000000:82:00.0 Off | N/A | | 68% 87C P2 197W / 250W | 10788MiB / 11172MiB | 88% Default | +-------------------------------+----------------------+----------------------+ | 3 GeForce GTX 108... Off | 00000000:83:00.0 Off | N/A | | 62% 86C P2 191W / 250W | 10788MiB / 11172MiB | 86% Default | +-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+ | Processes: GPU Memory | | GPU PID Type Process name Usage | |=============================================================================| | 0 1574 G /usr/lib/xorg/Xorg 120MiB | | 0 32468 G /usr/lib/firefox/firefox 4MiB | | 0 37191 G compiz 75MiB | | 0 46611 G /opt/teamviewer/tv_bin/TeamViewer 9MiB | | 1 22080 C python3 10775MiB | | 2 21777 C python3 10775MiB | | 3 21777 C python3 10775MiB | +-----------------------------------------------------------------------------+

I tried the multi-gpu training yesterday. Is batchsize evenly distributed to multi-gpu? I found that while I increased the number of GPU, batchsize=2xn (n: num of GPU). In addition, I am doing the detection of medical images (two classifications). Is it too small for batchsize=2? Or for the detection of colon cancer polyps and adenomas, could you recommend a smaller and more suitable model for me? Thank you very much!

jixiaonanzhuaizhuai avatar Aug 04 '18 01:08 jixiaonanzhuaizhuai

Would you mind sharing the entirety of your config, as well as the commands you use to run training?There's some extra flags required to run for multi-gpu. In addition, image resolution will also play a large role on how many images you can fit into a batch.

I think a FasterRCNN type model is probably appropriate for your use case, but maybe trying using ResNet101 or other feature extractors.

derekjchow avatar Aug 06 '18 18:08 derekjchow

this is my config:

Faster R-CNN with Inception Resnet v2, Atrous version;

Configured for MSCOCO 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_resnet_v2' first_stage_features_stride: 8 } 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: 8 width_stride: 8 } } first_stage_atrous_rate: 2 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: 17 maxpool_kernel_size: 1 maxpool_stride: 1 second_stage_box_predictor { mask_rcnn_box_predictor { use_dropout: false dropout_keep_probability: 1.0 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: 100 } score_converter: SOFTMAX } second_stage_localization_loss_weight: 2.0 second_stage_classification_loss_weight: 1.0 } }

train_config: { batch_size: 2 optimizer { momentum_optimizer: { learning_rate: { manual_step_learning_rate { initial_learning_rate: 0.0003 schedule { step: 35000 learning_rate: .00003 } schedule { step: 55000 learning_rate: .000003 } schedule { step: 100000 learning_rate: .0000003 } schedule { step: 120000 learning_rate: .00000003 } } } momentum_optimizer_value: 0.9 } use_moving_average: false } gradient_clipping_by_norm: 10.0 fine_tune_checkpoint: "modelF/faster_rcnn_inception_resnet_v2_atrous_coco_2018_01_28/model.ckpt" from_detection_checkpoint: 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: "modelF/train.record" } label_map_path: "modelF/tumour.pbtxt" }

eval_config: { num_examples: 488

Note: The below line limits the evaluation process to 10 evaluations.

Remove the below line to evaluate indefinitely.

#max_evals: 10 }

eval_input_reader: { tf_record_input_reader { input_path: "modelF/test.record" } label_map_path: "modelF/tumour.pbtxt" shuffle: false num_readers: 1 }


the commands I use to run training is CUDA_VISIBLE_DEVICES=1 python3 train.py --logtostderr --pipeline_config_path=modelF/faster_rcnn_inception_resnet_v2_atrous_coco.config --train_dir=modelF/train


the shape of my image is 500 x 500.

I hope you can give me some advice. Thanks!

jixiaonanzhuaizhuai avatar Aug 07 '18 01:08 jixiaonanzhuaizhuai

Hello @jixiaonanzhuaizhuai,

It looks like you are resizing images to 1024,600 not 500,500. You will be shrinking your network, which should allow at least a batch size of 2+ with a 1080ti

image_resizer { keep_aspect_ratio_resizer {

min_dimension: 600 max_dimension: 1024 } }

Can be changed to

image_resizer {

fixed_shape_resizer {

min_dimension: 500 max_dimension: 500 } }

twhitloc avatar Oct 11 '18 16:10 twhitloc

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.

tensorflowbutler avatar Jan 29 '20 23:01 tensorflowbutler