Skip to content
Snippets Groups Projects
99-Scripts-Tensorboard.ipynb 4.09 KiB
Newer Older
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<img width=\"800px\" src=\"../fidle/img/00-Fidle-header-01.svg\"></img>\n",
    "# <!-- TITLE --> [TSB1] - 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`"
Jean-Luc Parouty's avatar
Jean-Luc Parouty committed
   "execution_count": null,
   "metadata": {},
   "outputs": [],
    "%%bash\n",
    "tensorboard_start --logdir ./run/logs"
Jean-Luc Parouty's avatar
Jean-Luc Parouty committed
   "execution_count": null,
   "metadata": {},
   "outputs": [],
    "%%bash\n",
    "tensorboard_status"
Jean-Luc Parouty's avatar
Jean-Luc Parouty committed
   "execution_count": null,
Jean-Luc Parouty's avatar
Jean-Luc Parouty committed
   "outputs": [],
    "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 :"
   ]
  },
Jean-Luc Parouty's avatar
Jean-Luc Parouty committed
   "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",
   "metadata": {},
   "outputs": [],
   "source": [
    "import tensorboard.notebook as tsb"
   ]
  },
  {
   "cell_type": "code",
Jean-Luc Parouty's avatar
Jean-Luc Parouty committed
   "execution_count": null,
Jean-Luc Parouty's avatar
Jean-Luc Parouty committed
   "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",
Jean-Luc Parouty's avatar
Jean-Luc Parouty committed
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "!kill 214798"
   ]
  },
  {
   "cell_type": "markdown",
   "source": [
    "---\n",
    "<img width=\"80px\" src=\"../fidle/img/00-Fidle-logo-01.svg\"></img>"
  }
 ],
 "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",
Jean-Luc Parouty's avatar
Jean-Luc Parouty committed
   "version": "3.7.6"