{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "\n", "# <!-- TITLE --> Tensorboard with/from Jupyter \n", "<!-- DESC --> 4 ways to use Tensorboard from the Jupyter environment\n", "<!-- AUTHOR : Jean-Luc Parouty (CNRS/SIMaP) -->\n", "\n", "## Objectives :\n", " - Using Tensorboard\n", " - ...and if possible, simply and easily !\n", " \n", "About [Tensorboard](https://www.tensorflow.org/tensorboard/get_started)\n", "\n", "## What we're going to do :\n", " - Using Tensorboard" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Option 1 - From Jupyter\n", "It's the easiest and most fun way: Launch Tensorboard directly from Jupiter. \n", "Unfortunately, this feature seems to be a bit capricious with the recent versions of Jupyter... \n", "It works on Jean-Zay (at **IDRIS**), but on Jupyter Notebook." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Option 2 - Shell command\n", "That's what we're going to use in **GRICAD.** \n", "In fact, this is like starting tensorboard from the command line. \n", "More about it : `tensorboard --help`" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%%bash\n", "tensorboard_start --logdir ./run/logs" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%%bash\n", "tensorboard_status" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%%bash\n", "tensorboard_stop" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Option 3 - Magic command\n", "**Start**" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "%load_ext tensorboard" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "For example for use on a GRICAD cluster :" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%tensorboard --port 21277 --host 0.0.0.0 --logdir ./run/logs" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Stop** \n", "No way... use bash method\n", "\n", "## Option 4 - Tensorboard as a module\n", "\n", "**Start**" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import tensorboard.notebook as tsb" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "tsb.start('--port 21277 --host 0.0.0.0 --logdir ./run/logs')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Check**" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "No known TensorBoard instances running.\n" ] } ], "source": [ "a=tsb.list()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Stop** \n", "No way... use bash method" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "!kill 214798" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "---\n", "" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.6" } }, "nbformat": 4, "nbformat_minor": 4 }