Esempio n. 1
0
def main(unused_argv=None):
    if FLAGS.debug:
        logging.set_verbosity(logging.DEBUG)
        logging.info('TensorBoard is in debug mode.')

    if not FLAGS.logdir:
        logging.error(
            'A logdir must be specified. Run `tensorboard --help` for '
            'details and examples.')
        return -1

    logging.info('Starting TensorBoard in directory %s', os.getcwd())

    path_to_run = ParseEventFilesFlag(FLAGS.logdir)
    logging.info('TensorBoard path_to_run is: %s', path_to_run)
    multiplexer = event_multiplexer.EventMultiplexer(
        size_guidance=TENSORBOARD_SIZE_GUIDANCE)

    def _Load():
        start = time.time()
        for (path, name) in six.iteritems(path_to_run):
            multiplexer.AddRunsFromDirectory(path, name)
        multiplexer.Reload()
        duration = time.time() - start
        logging.info('Multiplexer done loading. Load took %0.1f secs',
                     duration)
        t = threading.Timer(LOAD_INTERVAL, _Load)
        t.daemon = True
        t.start()

    t = threading.Timer(0, _Load)
    t.daemon = True
    t.start()

    factory = functools.partial(tensorboard_handler.TensorboardHandler,
                                multiplexer)
    try:
        server = ThreadedHTTPServer((FLAGS.host, FLAGS.port), factory)
    except socket.error:
        logging.error(
            'Tried to connect to port %d, but that address is in use.',
            FLAGS.port)
        return -2
    try:
        tag = resource_loader.load_resource('tensorboard/TAG').strip()
        logging.info('TensorBoard is tag: %s', tag)
    except IOError:
        logging.warning('Unable to read TensorBoard tag')
        tag = ''

    status_bar.SetupStatusBarInsideGoogle('TensorBoard %s' % tag, FLAGS.port)
    print('Starting TensorBoard %s on port %d' % (tag, FLAGS.port))
    print('(You can navigate to http://%s:%d)' % (FLAGS.host, FLAGS.port))
    server.serve_forever()
Esempio n. 2
0
def main(unused_argv=None):
    if FLAGS.debug:
        logging.set_verbosity(logging.DEBUG)
        logging.info('TensorBoard is in debug mode.')

    if FLAGS.inspect:
        logging.info(
            'Not bringing up TensorBoard, but inspecting event files.')
        efi.inspect(logdir=FLAGS.logdir,
                    event_file=FLAGS.event_file,
                    tag=FLAGS.tag)
        return 0

    if not FLAGS.logdir:
        msg = ('A logdir must be specified. Run `tensorboard --help` for '
               'details and examples.')
        logging.error(msg)
        print(msg)
        return -1

    logging.info('Starting TensorBoard in directory %s', os.getcwd())
    path_to_run = server.ParseEventFilesSpec(FLAGS.logdir)
    logging.info('TensorBoard path_to_run is: %s', path_to_run)

    multiplexer = event_multiplexer.EventMultiplexer(
        size_guidance=server.TENSORBOARD_SIZE_GUIDANCE,
        purge_orphaned_data=FLAGS.purge_orphaned_data)
    server.StartMultiplexerReloadingThread(multiplexer, path_to_run,
                                           FLAGS.reload_interval)
    try:
        tb_server = server.BuildServer(multiplexer, FLAGS.host, FLAGS.port)
    except socket.error:
        if FLAGS.port == 0:
            msg = 'Unable to find any open ports.'
            logging.error(msg)
            print(msg)
            return -2
        else:
            msg = 'Tried to connect to port %d, but address is in use.' % FLAGS.port
            logging.error(msg)
            print(msg)
            return -3

    try:
        tag = resource_loader.load_resource('tensorboard/TAG').strip()
        logging.info('TensorBoard is tag: %s', tag)
    except IOError:
        logging.warning('Unable to read TensorBoard tag')
        tag = ''

    status_bar.SetupStatusBarInsideGoogle('TensorBoard %s' % tag, FLAGS.port)
    print('Starting TensorBoard %s on port %d' % (tag, FLAGS.port))
    print('(You can navigate to http://%s:%d)' % (FLAGS.host, FLAGS.port))
    tb_server.serve_forever()
Esempio n. 3
0
def main(unused_argv=None):
    if FLAGS.debug:
        logging.set_verbosity(logging.DEBUG)
        logging.info('TensorBoard is in debug mode.')

    if not FLAGS.logdir:
        logging.error(
            'A logdir must be specified. Run `tensorboard --help` for '
            'details and examples.')
        return -1

    if FLAGS.debug:
        logging.info('Starting TensorBoard in directory %s', os.getcwd())

    path_to_run = ParseEventFilesFlag(FLAGS.logdir)
    multiplexer = event_multiplexer.AutoloadingMultiplexer(
        path_to_run=path_to_run,
        interval_secs=60,
        size_guidance=TENSORBOARD_SIZE_GUIDANCE)

    multiplexer.AutoUpdate(interval=30)

    factory = functools.partial(tensorboard_handler.TensorboardHandler,
                                multiplexer)
    try:
        server = ThreadedHTTPServer((FLAGS.host, FLAGS.port), factory)
    except socket.error:
        logging.error(
            'Tried to connect to port %d, but that address is in use.',
            FLAGS.port)
        return -2
    try:
        tag = resource_loader.load_resource('tensorboard/TAG').strip()
        logging.info('TensorBoard is tag: %s', tag)
    except IOError:
        logging.warning('Unable to read TensorBoard tag')
        tag = ''

    status_bar.SetupStatusBarInsideGoogle('TensorBoard %s' % tag, FLAGS.port)
    print('Starting TensorBoard %s on port %d' % (tag, FLAGS.port))
    print('(You can navigate to http://%s:%d)' % (FLAGS.host, FLAGS.port))
    server.serve_forever()
Esempio n. 4
0
def main(unused_argv=None):
    # Change current working directory to tensorflow/'s parent directory.
    server_root = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir)
    os.chdir(server_root)

    if FLAGS.debug:
        logging.set_verbosity(logging.DEBUG)

    if not FLAGS.logdir:
        logging.error(
            'A logdir must be specified. Run `tensorboard --help` for '
            'details and examples.')
        return -1

    if FLAGS.debug:
        logging.info('Starting TensorBoard in directory %s', os.getcwd())

    path_to_run = ParseEventFilesFlag(FLAGS.logdir)
    multiplexer = event_multiplexer.AutoloadingMultiplexer(
        path_to_run=path_to_run,
        interval_secs=60,
        size_guidance=TENSORBOARD_SIZE_GUIDANCE)

    multiplexer.AutoUpdate(interval=30)

    factory = functools.partial(tensorboard_handler.TensorboardHandler,
                                multiplexer)
    try:
        server = ThreadedHTTPServer((FLAGS.host, FLAGS.port), factory)
    except socket.error:
        logging.error(
            'Tried to connect to port %d, but that address is in use.',
            FLAGS.port)
        return -2

    status_bar.SetupStatusBarInsideGoogle('TensorBoard', FLAGS.port)
    print('Starting TensorBoard on port %d' % FLAGS.port)
    print('(You can navigate to http://localhost:%d)' % FLAGS.port)
    server.serve_forever()
Esempio n. 5
0
def main(unused_argv=None):
    debug = FLAGS.insecure_debug_mode
    logdir = os.path.expanduser(FLAGS.logdir)
    if debug:
        logging.set_verbosity(logging.DEBUG)
        logging.warning('TensorBoard is in debug mode. This is NOT SECURE.')

    if FLAGS.inspect:
        logging.info(
            'Not bringing up TensorBoard, but inspecting event files.')
        event_file = os.path.expanduser(FLAGS.event_file)
        efi.inspect(logdir, event_file, FLAGS.tag)
        return 0

    if not logdir:
        msg = ('A logdir must be specified. Run `tensorboard --help` for '
               'details and examples.')
        logging.error(msg)
        print(msg)
        return -1

    logging.info('Starting TensorBoard in directory %s', os.getcwd())

    plugins = {'projector': projector_plugin.ProjectorPlugin()}
    tb_app = application.TensorBoardWSGIApp(
        logdir,
        plugins,
        purge_orphaned_data=FLAGS.purge_orphaned_data,
        reload_interval=FLAGS.reload_interval)

    try:
        tag = resource_loader.load_resource('tensorboard/TAG').strip()
        logging.info('TensorBoard is tag: %s', tag)
    except IOError:
        logging.info('Unable to read TensorBoard tag')
        tag = ''

    status_bar.SetupStatusBarInsideGoogle('TensorBoard %s' % tag, FLAGS.port)
    print('Starting TensorBoard %s on port %d' % (tag, FLAGS.port))

    if FLAGS.host == "0.0.0.0":
        try:
            host = socket.gethostbyname(socket.gethostname())
            print('(You can navigate to http://%s:%d)' % (host, FLAGS.port))
        except socket.gaierror:
            pass
    else:
        print('(You can navigate to http://%s:%d)' % (FLAGS.host, FLAGS.port))

    try:
        serving.run_simple(FLAGS.host,
                           FLAGS.port,
                           tb_app,
                           threaded=True,
                           use_reloader=debug,
                           use_evalex=debug,
                           use_debugger=debug)
    except socket.error:
        if FLAGS.port == 0:
            msg = 'Unable to find any open ports.'
            logging.error(msg)
            print(msg)
            return -2
        else:
            msg = 'Tried to connect to port %d, but address is in use.' % FLAGS.port
            logging.error(msg)
            print(msg)
            return -3