Skip to content
Snippets Groups Projects
06-Full-convolutions-batch.ipynb 5.79 KiB
Newer Older
Jean-Luc Parouty's avatar
Jean-Luc Parouty committed
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<img width=\"800px\" src=\"../fidle/img/00-Fidle-header-01.svg\"></img>\n",
    "\n",
    "# <!-- TITLE --> [GTS6] - CNN with GTSRB dataset - Full convolutions as a batch\n",
    "<!-- DESC --> Episode 6 : Run Full convolution notebook as a batch\n",
    "<!-- AUTHOR : Jean-Luc Parouty (CNRS/SIMaP) -->\n",
Jean-Luc Parouty's avatar
Jean-Luc Parouty committed
    "\n",
    "## Objectives :\n",
    "  - Run a notebook code as a **job**\n",
    "  - Follow up with Tensorboard\n",
    "  \n",
    "The German Traffic Sign Recognition Benchmark (GTSRB) is a dataset with more than 50,000 photos of road signs from about 40 classes.  \n",
    "The final aim is to recognise them !  \n",
    "Description is available there : http://benchmark.ini.rub.de/?section=gtsrb&subsection=dataset\n",
Jean-Luc Parouty's avatar
Jean-Luc Parouty committed
    "\n",
    "\n",
    "## What we're going to do :\n",
Jean-Luc Parouty's avatar
Jean-Luc Parouty committed
    "Our main steps:\n",
    " - Run Full-convolution.ipynb as a batch :\n",
    "    - Notebook mode\n",
    "    - Script mode \n",
    " - Tensorboard follow up\n",
    "    \n",
    "## Step 1 - Run a notebook as a batch\n",
    "To run a notebook in a command line :  \n",
    "```jupyter nbconvert (...) --to notebook --execute <notebook>```"
Jean-Luc Parouty's avatar
Jean-Luc Parouty committed
   ]
  },
  {
Jean-Luc Parouty's avatar
Jean-Luc Parouty committed
   "metadata": {},
   "source": [
    "%%bash\n",
    "\n",
    "# ---- This will execute and save a notebook\n",
    "#\n",
    "jupyter nbconvert --ExecutePreprocessor.timeout=-1 --to notebook --output='./run/full_convolutions' --execute '05-Full-convolutions.ipynb'\n"
Jean-Luc Parouty's avatar
Jean-Luc Parouty committed
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Step 2 - Export as a script (What we're going to do !)\n",
Jean-Luc Parouty's avatar
Jean-Luc Parouty committed
    "To export a notebook as a script :  \n",
    "```jupyter nbconvert --to script <notebook>```  \n",
    "To run the script :  \n",
    "```ipython <script>```"
Jean-Luc Parouty's avatar
Jean-Luc Parouty committed
   ]
  },
  {
   "cell_type": "code",
Jean-Luc Parouty's avatar
Jean-Luc Parouty committed
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "[NbConvertApp] Converting notebook 05-Full-convolutions.ipynb to script\n",
Jean-Luc Parouty's avatar
Jean-Luc Parouty committed
      "[NbConvertApp] Writing 11305 bytes to ./run/full_convolutions_B.py\n"
Jean-Luc Parouty's avatar
Jean-Luc Parouty committed
     ]
    }
   ],
   "source": [
    "%%bash\n",
    "\n",
    "# ---- This will convert a notebook to a notebook.py script\n",
Jean-Luc Parouty's avatar
Jean-Luc Parouty committed
    "#\n",
Jean-Luc Parouty's avatar
Jean-Luc Parouty committed
    "jupyter nbconvert --to script --output='./run/full_convolutions_B' '05-Full-convolutions.ipynb'"
Jean-Luc Parouty's avatar
Jean-Luc Parouty committed
   ]
  },
  {
   "cell_type": "code",
Jean-Luc Parouty's avatar
Jean-Luc Parouty committed
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
Jean-Luc Parouty's avatar
Jean-Luc Parouty committed
      "-rw-r--r-- 1 pjluc pjluc 11305 Jan 21 00:13 ./run/full_convolutions_B.py\n"
Jean-Luc Parouty's avatar
Jean-Luc Parouty committed
     ]
    }
   ],
   "source": [
Jean-Luc Parouty's avatar
Jean-Luc Parouty committed
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Step 2 - Batch submission\n",
Jean-Luc Parouty's avatar
Jean-Luc Parouty committed
    "Create batch script :"
   ]
  },
  {
   "cell_type": "code",
Jean-Luc Parouty's avatar
Jean-Luc Parouty committed
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
Jean-Luc Parouty's avatar
Jean-Luc Parouty committed
      "Writing ./run/batch_full_convolutions_B.sh\n"
Jean-Luc Parouty's avatar
Jean-Luc Parouty committed
     ]
    }
   ],
   "source": [
Jean-Luc Parouty's avatar
Jean-Luc Parouty committed
    "%%writefile \"./run/batch_full_convolutions_B.sh\"\n",
    "#!/bin/bash\n",
    "#OAR -n Full convolutions\n",
    "#OAR -t gpu\n",
    "#OAR -l /nodes=1/gpudevice=1,walltime=01:00:00\n",
    "#OAR --stdout full_convolutions_%jobid%.out\n",
    "#OAR --stderr full_convolutions_%jobid%.err\n",
    "#OAR --project fidle\n",
Jean-Luc Parouty's avatar
Jean-Luc Parouty committed
    "\n",
    "#---- With cpu\n",
    "# use :\n",
    "# OAR -l /nodes=1/core=32,walltime=01:00:00\n",
    "# and add a 2>/dev/null to ipython xxx\n",
Jean-Luc Parouty's avatar
Jean-Luc Parouty committed
    "\n",
    "# ----------------------------------\n",
    "#   _           _       _\n",
    "#  | |__   __ _| |_ ___| |__\n",
    "#  | '_ \\ / _` | __/ __| '_ \\\n",
    "#  | |_) | (_| | || (__| | | |\n",
    "#  |_.__/ \\__,_|\\__\\___|_| |_|\n",
    "#                  Full convolutions\n",
    "# ----------------------------------\n",
    "#\n",
    "\n",
    "CONDA_ENV=deeplearning2\n",
    "RUN_DIR=~/fidle/GTSRB\n",
Jean-Luc Parouty's avatar
Jean-Luc Parouty committed
    "RUN_SCRIPT=./run/full_convolutions_B.py\n",
Jean-Luc Parouty's avatar
Jean-Luc Parouty committed
    "\n",
    "# ---- Cuda Conda initialization\n",
    "#\n",
    "echo '------------------------------------------------------------'\n",
    "echo \"Start : $0\"\n",
    "echo '------------------------------------------------------------'\n",
    "#\n",
Jean-Luc Parouty's avatar
Jean-Luc Parouty committed
    "source /applis/environments/cuda_env.sh dahu 10.0\n",
    "source /applis/environments/conda.sh\n",
    "#\n",
    "conda activate \"$CONDA_ENV\"\n",
    "\n",
    "# ---- Run it...\n",
    "#\n",
    "cd $RUN_DIR\n",
    "ipython $RUN_SCRIPT"
   ]
  },
  {
   "cell_type": "code",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
Jean-Luc Parouty's avatar
Jean-Luc Parouty committed
      "-rwxr-xr-x 1 pjluc pjluc  1045 Jan 21 00:15 ./run/batch_full_convolutions_B.sh\n",
      "-rwxr-xr-x 1 pjluc pjluc   611 Jan 19 15:53 ./run/batch_full_convolutions.sh\n",
      "-rwxr-xr-x 1 pjluc pjluc 11305 Jan 21 00:13 ./run/full_convolutions_B.py\n"
    "chmod 755 ./run/*.sh\n",
    "chmod 755 ./run/*.py\n",
    "ls -l ./run/*full_convolutions*"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": [
    "%%bash\n",
    "./run/batch_full_convolutions.sh\n",
    "oarsub (...)"
Jean-Luc Parouty's avatar
Jean-Luc Parouty committed
   ]
  },
  {
   "cell_type": "markdown",
Jean-Luc Parouty's avatar
Jean-Luc Parouty committed
   "metadata": {},
   "source": [
    "---\n",
    "<img width=\"80px\" src=\"../fidle/img/00-Fidle-logo-01.svg\"></img>"
Jean-Luc Parouty's avatar
Jean-Luc Parouty committed
  }
 ],
 "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"
Jean-Luc Parouty's avatar
Jean-Luc Parouty committed
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}