Why the my Tensorflow code just use one GPU when I assign more than one
If a TensorFlow operation has both CPU and GPU implementations, TensorFlow will automatically place the operation to run on a GPU device first. If you have more than one GPU, the GPU with the lowest ID will be selected by default.
TensorFlow 2.0 now has the tf.distribute module to distribute training across multiple GPUs, multiple machines or TPUs. It builds on the concept of &quot;distribution strategies&quot;. You can use tf.distribute.MirroredStrategy() as a scope, like
strategy = tf.distribute.MirroredStrategy()
with strategy.scope():
    #DO WHATEVER YOU WANT TO DO HERE

Please check this Distributed training with TensorFlow guide for implementation details and other strategies.