Last active
June 3, 2020 19:32
-
-
Save usuyama/8c68fab8d70e349add026d906828ec40 to your computer and use it in GitHub Desktop.
Tensorboard with AzureML
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
''' | |
https://docs.microsoft.com/en-us/azure/machine-learning/how-to-monitor-tensorboard | |
make sure to install | |
pip install tensorflow azureml-tensorboard | |
Tensorboard logs need to be written in the logs folder by AML training runs. | |
SummaryWriter(log_dir="logs/test_run") | |
''' | |
from azureml.tensorboard import Tensorboard | |
from azureml.core import Workspace, Experiment | |
import argparse | |
parser = argparse.ArgumentParser() | |
parser.add_argument('experiment') | |
parser.add_argument('--workspace-config', default="config.json") | |
args = parser.parse_args() | |
print(args) | |
ws = Workspace.from_config(path=args.workspace_config) | |
print('=' * 40) | |
print(ws) | |
exp = Experiment(ws, args.experiment) | |
print(exp) | |
runs = [] | |
for run in exp.get_runs(): | |
if run.get_status() == 'Failed': | |
continue | |
print(run.id, run.get_status()) | |
runs.append(run) | |
local_root = 'tb_local_root' | |
tb = Tensorboard(runs, local_root=local_root) | |
print(f"Tensorboard logs will be downloaded to {local_root}") | |
tb.start() | |
# Make sure to keep the program running (or use it on a Jupyter notebook) | |
while True: | |
input_data = input("Stop the tensorboard server? [y]") | |
if input_data in ['y']: | |
break | |
tb.stop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment