Unverified Commit 9efce4fe authored by SparkSnail's avatar SparkSnail Committed by GitHub
Browse files

Support tensorboard 2.x command (#2242)

parent 39cd591b
...@@ -76,6 +76,14 @@ def get_python_dir(sitepackages_path): ...@@ -76,6 +76,14 @@ def get_python_dir(sitepackages_path):
else: else:
return str(Path(sitepackages_path).parents[2]) return str(Path(sitepackages_path).parents[2])
def check_tensorboard_version():
try:
import tensorboard
return tensorboard.__version__
except:
print_error('import tensorboard error!')
exit(1)
def get_nni_installation_path(): def get_nni_installation_path():
''' Find nni lib from the following locations in order ''' Find nni lib from the following locations in order
Return nni root directory if it exists Return nni root directory if it exists
......
...@@ -10,7 +10,7 @@ from .rest_utils import rest_get, check_rest_server_quick, check_response ...@@ -10,7 +10,7 @@ from .rest_utils import rest_get, check_rest_server_quick, check_response
from .config_utils import Config, Experiments from .config_utils import Config, Experiments
from .url_utils import trial_jobs_url, get_local_urls from .url_utils import trial_jobs_url, get_local_urls
from .constants import COLOR_GREEN_FORMAT, REST_TIME_OUT from .constants import COLOR_GREEN_FORMAT, REST_TIME_OUT
from .common_utils import print_normal, print_error, detect_process, detect_port from .common_utils import print_normal, print_error, detect_process, detect_port, check_tensorboard_version
from .nnictl_utils import check_experiment_id, check_experiment_id from .nnictl_utils import check_experiment_id, check_experiment_id
from .ssh_utils import create_ssh_sftp_client, copy_remote_directory_to_local from .ssh_utils import create_ssh_sftp_client, copy_remote_directory_to_local
...@@ -77,7 +77,8 @@ def start_tensorboard_process(args, nni_config, path_list, temp_nni_path): ...@@ -77,7 +77,8 @@ def start_tensorboard_process(args, nni_config, path_list, temp_nni_path):
exit(1) exit(1)
with open(os.path.join(temp_nni_path, 'tensorboard_stdout'), 'a+') as stdout_file, \ with open(os.path.join(temp_nni_path, 'tensorboard_stdout'), 'a+') as stdout_file, \
open(os.path.join(temp_nni_path, 'tensorboard_stderr'), 'a+') as stderr_file: open(os.path.join(temp_nni_path, 'tensorboard_stderr'), 'a+') as stderr_file:
cmds = ['tensorboard', '--logdir', format_tensorboard_log_path(path_list), '--port', str(args.port)] log_dir_cmd = '--logdir_spec' if check_tensorboard_version() >= '2.0' else '--logdir'
cmds = ['tensorboard', log_dir_cmd, format_tensorboard_log_path(path_list), '--port', str(args.port)]
tensorboard_process = Popen(cmds, stdout=stdout_file, stderr=stderr_file) tensorboard_process = Popen(cmds, stdout=stdout_file, stderr=stderr_file)
url_list = get_local_urls(args.port) url_list = get_local_urls(args.port)
print_normal(COLOR_GREEN_FORMAT % 'Start tensorboard success!\n' + 'Tensorboard urls: ' + ' '.join(url_list)) print_normal(COLOR_GREEN_FORMAT % 'Start tensorboard success!\n' + 'Tensorboard urls: ' + ' '.join(url_list))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment