xtudbxk / DSRG-tensorflow

a tensorflow version for DSRG (Weakly-Supervised Semantic Segmentation Network with Deep Seeded Region Growing)
75 stars 20 forks source link

train on multiple gpus #10

Closed WeitaoVan closed 5 years ago

WeitaoVan commented 5 years ago

Thanks very much for your code.

The script accepts arguments like 0,1,2,3 to specify multiple gpus. However, only 1 gpu is actually used for computation.

Could you explain how to train with multiple gpus?

Thanks!

xtudbxk commented 5 years ago

Yes, it is. Even multi gpus are available, only the first gpu is used for building the model in Tensorflow. To make use of the left gpus, you should use 'tf.device("/gpu:0")' to set the gpu used for each operations. What's more, the "colocate_gradients_with_ops" should be True when call the tf.compute_gradients. This makes the gradients of each ops are allocated on the same gpu with the operation. For more information, you can search "tf.device" and "colocate_gradients_with_ops" by search engine.