david8862 / keras-YOLOv3-model-set

end-to-end YOLOv4/v3/v2 object detection pipeline, implemented on tf.keras with different technologies
MIT License
639 stars 222 forks source link

NotImplementedError: `fit_generator` is not supported for models compiled with tf.distribute.Strategy. #106

Open Liuhsinche opened 4 years ago

Liuhsinche commented 4 years ago

Hi, I encountered this error when trying to train with multiple GPUs: NotImplementedError:fit_generatoris not supported for models compiled with tf.distribute.Strategy.

The command I ran at the time was like this:

python train.py \
    --model_type=yolo3_mobilenet_lite \
    --anchors_path=configs/yolo-dac_anchors.txt \
    --model_image_size=160x320 \
    --annotation_file=/media/NAS/share/DataSets/DAC/dac_train.txt \
    --val_annotation_file=/media/NAS/share/DataSets/DAC/dac_val.txt \
    --classes_path=configs/dac_classes.txt \
    --multiscale \
    --gpu_num=3 \
    --eval_online \
    --save_eval_checkpoint

My environment is like this:

Ubuntu 18.04.4
Python 3.6.8
TensorFlow 2.0.0
Keras 2.2.4
Numpy 1.17.5

Do you know what might be the reason? Thanks a lot.

david8862 commented 4 years ago

seems it's a TF 2.0 version issue https://github.com/tensorflow/tensorflow/issues/31231 https://github.com/tensorflow/tensorflow/issues/33725

maybe you can try to upgrade to TF 2.1+, and use "model.fit()" to replace "model.fit_generator()" if still doesn't work