-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #172 from aws-samples/smhp-time-sync
SMHP time sync
- Loading branch information
Showing
2 changed files
with
39 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
36 changes: 36 additions & 0 deletions
36
1.architectures/5.sagemaker-hyperpod/LifecycleScripts/base-config/utils/setup_timesync.sh
This file contains 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,36 @@ | ||
#!/bin/bash | ||
|
||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# SPDX-License-Identifier: MIT-0 | ||
|
||
# Credits: Sean Smith, Ben Snyder, Shubham Arora | ||
# | ||
# Consistent times across cluster is crucial for distributed workload. For example, torchrun fails | ||
# fast when it detects 5 seconds (or more) time differences among workers. | ||
# | ||
# Check the time of all compute nodes as follows: | ||
# | ||
# srun -N <NUM_OF_NODES> bash -c 'echo "$(hostname): $(date)"' | sort -k2,3 | ||
# | ||
# | ||
# To avoid time drifts, enable time synchornization (ref: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/set-time.html). | ||
|
||
set -exuo pipefail | ||
|
||
FILE=/etc/chrony/chrony.conf | ||
|
||
line='server 169.254.169.123 prefer iburst minpoll 4 maxpoll 4' | ||
grep "^${line}$" $FILE &> /dev/null \ | ||
&& echo Line \"${line}\" already exists in $FILE \ | ||
|| sed -i \ | ||
"/\# See http:\/\/www.pool.ntp.org\/join.html for more information./a ${line}" \ | ||
$FILE | ||
|
||
line='pool time.aws.com iburst' | ||
grep "^${line}$" $FILE &> /dev/null \ | ||
&& echo Line \"${line}\" already exists in $FILE \ | ||
|| sed -i \ | ||
"/^server 169.254.169.123 prefer iburst minpoll 4 maxpoll 4$/a ${line}" \ | ||
$FILE | ||
|
||
systemctl enable --now chrony |