-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Support of Horovod and TF 1.12 for TensorFlow Script Mode. TFS 1.12 support #567
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
Changes from all commits
Commits
Show all changes
69 commits
Select commit
Hold shift + click to select a range
1eb85ad
Add horovod support
icywang86rui c63fe06
Add newline at eof
icywang86rui b91208a
Do not skip integ test
icywang86rui a1b426a
Edit README to include distributed training with MPI
icywang86rui 10fe7bf
PR commentsw
icywang86rui c5f68b1
Add processes_per_host and custom_mpi_options
icywang86rui 858079e
Add missing period
icywang86rui ffc0812
Use distribution in README
icywang86rui 7587e52
Use distributions in README
icywang86rui f1f8583
Fix README
icywang86rui 64449a5
Imporve documentation
yangaws c857afe
Address comments from Eric
yangaws 245b75f
Merge remote-tracking branch 'origin/master' into horovod
mvsusp e3aeb6e
Updated TF version
mvsusp 2bcd290
Fix empty mpi distribution use case
mvsusp 3cfdc57
Add check for necessary files in model.tar.gz
yangaws 561414f
Add benchmarks as submodule
mvsusp b5d4a1c
Add benchmarks as submodule
mvsusp 7843392
Handle PR comments
mvsusp 1c4e8c5
Update version
mvsusp 41175a2
Handle PR comments
mvsusp c137be1
Run TF tests against latest container instead of default.
nadiaya d44d590
Merge branch 'wru-horovod' of github.com:mvsusp/sagemaker-python-sdk …
nadiaya 05ee7c1
Merge branch 'master' into wru-horovod
yangaws 1680073
Fix urllib.parse import errors for python 2.
nadiaya 0232e4a
Merge branch 'wru-horovod' of github.com:mvsusp/sagemaker-python-sdk …
nadiaya c19021a
Fix horovod integ test tar file extract error
yangaws 6722c07
Merge branch 'master' into wru-horovod
yangaws 24a5d61
fix flake8
yangaws 160e646
Removed unnecessary tests
mvsusp 7f93812
Merge branch 'master' into wru-horovod
uditbhatia 333ebf7
Removing duplicated/unused TF import
uditbhatia 1f80caf
Merge branch 'master' into wru-horovod
uditbhatia a1ec1b4
Add horovod support
icywang86rui 9e8d88a
Add newline at eof
icywang86rui fafc9bb
Do not skip integ test
icywang86rui df313d8
Edit README to include distributed training with MPI
icywang86rui 3fd1bf0
PR commentsw
icywang86rui e3051da
Add processes_per_host and custom_mpi_options
icywang86rui ead6229
Add missing period
icywang86rui d41e163
Use distribution in README
icywang86rui 2aff9fc
Use distributions in README
icywang86rui 3915406
Fix README
icywang86rui a07c0d6
Imporve documentation
yangaws 308a31c
Address comments from Eric
yangaws 56d6d07
Updated TF version
mvsusp 3145ffd
Fix empty mpi distribution use case
mvsusp dd838ef
Add check for necessary files in model.tar.gz
yangaws 15bfe00
Add benchmarks as submodule
mvsusp 8e9734e
Add benchmarks as submodule
mvsusp b22671d
Handle PR comments
mvsusp 20e906e
Update version
mvsusp 430cd0a
Handle PR comments
mvsusp bd9c92d
Run TF tests against latest container instead of default.
nadiaya 2fcdaea
Fix urllib.parse import errors for python 2.
nadiaya 3d06e11
Fix horovod integ test tar file extract error
yangaws c78eb31
fix flake8
yangaws abce1dd
Removed unnecessary tests
mvsusp 3342e94
Removing duplicated/unused TF import
uditbhatia cb7610f
Capitalizing the mpi_distribution ps_distribution constant
uditbhatia dca2173
resolving conflists
uditbhatia f91b29c
Merge branch 'master' into wru-horovod
uditbhatia 30995dd
Restoring version default to 1.12
uditbhatia 7c93fdc
Accomodating the mvs pr comments
uditbhatia a8d2cb0
Updating changelog
uditbhatia 55c1998
chaing the TF_VERSION field to 1.11 from 1.12 in defaults.py
uditbhatia c913c40
Merge branch 'master' into wru-horovod
uditbhatia 23d8074
Fixing flake 8 errors after merge from master and updating changelog
uditbhatia 177f37f
Bumping up the python SDK version to 1.17.3 (as per instructions in M…
uditbhatia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env bash | ||
|
||
python benchmarks/scripts/tf_cnn_benchmarks/tf_cnn_benchmarks.py --num_batches=500 --model vgg16 --variable_update horovod --horovod_device gpu --use_fp16 --summary_verbosity 1 --save_summaries_steps 10 --train_dir /opt/ml/model --eval_dir /opt/ml/model --batch_size 32 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import json | ||
import os | ||
import horovod.tensorflow as hvd | ||
|
||
hvd.init() | ||
|
||
with open(os.path.join('/opt/ml/model/rank-%s' % hvd.rank()), 'w+') as f: | ||
basic_info = {'rank': hvd.rank(), 'size': hvd.size()} | ||
|
||
print(basic_info) | ||
json.dump(basic_info, f) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
# Copyright 2017-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"). You | ||
# may not use this file except in compliance with the License. A copy of | ||
# the License is located at | ||
# | ||
# http://aws.amazon.com/apache2.0/ | ||
# | ||
# or in the "license" file accompanying this file. This file is | ||
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF | ||
# ANY KIND, either express or implied. See the License for the specific | ||
# language governing permissions and limitations under the License. | ||
from __future__ import absolute_import | ||
|
||
import json | ||
import os | ||
import tarfile | ||
from six.moves.urllib.parse import urlparse | ||
|
||
import boto3 | ||
import pytest | ||
|
||
import tests.integ as integ | ||
from sagemaker.tensorflow import TensorFlow | ||
from tests.integ import timeout | ||
|
||
horovod_dir = os.path.join(os.path.dirname(__file__), '..', 'data', 'horovod') | ||
|
||
|
||
@pytest.mark.parametrize('instance_type', ['ml.c5.xlarge', 'ml.p3.2xlarge']) | ||
def test_horovod(sagemaker_session, instance_type, tmpdir): | ||
|
||
estimator = TensorFlow(entry_point=os.path.join(horovod_dir, 'test_hvd_basic.py'), | ||
role='SageMakerRole', | ||
train_instance_count=2, | ||
train_instance_type=instance_type, | ||
sagemaker_session=sagemaker_session, | ||
py_version=integ.PYTHON_VERSION, | ||
script_mode=True, | ||
framework_version='1.12', | ||
distributions={'mpi': {'enabled': True}}, | ||
base_job_name='test-tf-horovod') | ||
|
||
with timeout.timeout(minutes=integ.TRAINING_DEFAULT_TIMEOUT_MINUTES): | ||
estimator.fit() | ||
|
||
tmp = str(tmpdir) | ||
extract_files_from_s3(estimator.model_data, tmp) | ||
|
||
for rank in range(2): | ||
assert read_json('rank-%s' % rank, tmp)['rank'] == rank | ||
|
||
|
||
@pytest.mark.parametrize('instances, processes', [ | ||
[1, 2], | ||
(2, 1), | ||
(2, 2)]) | ||
def test_horovod_local_mode(instances, processes, tmpdir): | ||
output_path = 'file://%s' % tmpdir | ||
|
||
estimator = TensorFlow(entry_point=os.path.join(horovod_dir, 'test_hvd_basic.py'), | ||
role='SageMakerRole', | ||
train_instance_count=2, | ||
train_instance_type='local', | ||
py_version=integ.PYTHON_VERSION, | ||
script_mode=True, | ||
output_path=output_path, | ||
framework_version='1.12', | ||
distributions={'mpi': {'enabled': True, | ||
'processes_per_host': processes}}, | ||
base_job_name='test-tf-horovod') | ||
|
||
with timeout.timeout(minutes=integ.TRAINING_DEFAULT_TIMEOUT_MINUTES): | ||
estimator.fit() | ||
|
||
tmp = str(tmpdir) | ||
extract_files(output_path.replace('file://', ''), tmp) | ||
|
||
size = instances * processes | ||
|
||
for rank in range(size): | ||
assert read_json('rank-%s' % rank, tmp)['rank'] == rank | ||
|
||
|
||
def extract_files(output_path, tmpdir): | ||
with tarfile.open(os.path.join(output_path, 'model.tar.gz')) as tar: | ||
tar.extractall(tmpdir) | ||
|
||
|
||
def read_json(file, tmp): | ||
with open(os.path.join(tmp, file)) as f: | ||
return json.load(f) | ||
|
||
|
||
def extract_files_from_s3(s3_url, tmpdir): | ||
parsed_url = urlparse(s3_url) | ||
s3 = boto3.resource('s3') | ||
|
||
model = os.path.join(tmpdir, 'model') | ||
s3.Bucket(parsed_url.netloc).download_file(parsed_url.path.lstrip('/'), model) | ||
|
||
with tarfile.open(model, 'r') as tar_file: | ||
tar_file.extractall(tmpdir) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.