Skip to content

Fix bug on distributed training in mnist using MirroredStrategy API #5183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 28, 2018

Conversation

parkjaeman
Copy link
Contributor

I tried to run distributed tensorflow with mnist but it did not work. So I fixed such problem with MirroredStrategy API.

@parkjaeman parkjaeman requested review from karmel and a team as code owners August 24, 2018 09:37
@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here (e.g. I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

@parkjaeman
Copy link
Contributor Author

I signed it!

@googlebot
Copy link

CLAs look good, thanks!

@karmel karmel requested review from robieta and guptapriya and removed request for karmel August 24, 2018 16:16
@karmel
Copy link
Contributor

karmel commented Aug 24, 2018

Thanks for the PR, @parkjaeman . @robieta , @guptapriya -- can you take a look?

Copy link
Contributor

@robieta robieta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two broad changes to make:

  1. Remove the multi_gpu flag and replace it with num_gpus. (See other models such as wide deep and resnet) This will also allow you to use utils.misc.distribution_utils.get_distribution_strategy() to get the distribution.

  2. Remove TowerOptimizer; it is not needed once replicate_model_fn is removed.

@@ -125,7 +125,10 @@ def model_fn(features, labels, mode, params):

logits = model(image, training=True)
loss = tf.losses.sparse_softmax_cross_entropy(labels=labels, logits=logits)
accuracy = tf.metrics.accuracy(
if params.get('multi_gpu'):
accuracy = (tf.no_op(), tf.constant(0))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be necessary. If you are having issues make sure your version of tf-nightly is up to date.

Copy link
Contributor Author

@parkjaeman parkjaeman Aug 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@robieta, I applied your comments to this PR like

  • Remove multi_gpu
  • Remove TowerOptimizer
  • Replace MirroredStrategy with distribution_utils.get_distribution_strategy()

And I checked mnist run without error when I add parameter '--num_gpus'.

- Remove multi-gpu
- Remove TowerOptimizer
- Change from MirroredStrategy to distribution_utils.get_distribution_strategy
Copy link
Contributor

@robieta robieta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for looking into this.

@robieta robieta merged commit 6a0dda1 into tensorflow:master Aug 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants