Skip to content
Snippets Groups Projects
05.1-Full-convolutions-batch.ipynb 5.22 KiB
Newer Older
Jean-Luc Parouty's avatar
Jean-Luc Parouty committed
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "German Traffic Sign Recognition Benchmark (GTSRB)\n",
    "=================================================\n",
    "---\n",
    "Introduction au Deep Learning  (IDLE) - S. Arias, E. Maldonado, JL. Parouty - CNRS/SARI/DEVLOG - 2020  \n",
    "\n",
    "## Episode 5.1 : Full Convolutions / run\n",
    "\n",
    "Our main steps:\n",
    " - Run Full-convolution.ipynb as a batch :\n",
    "    - Notebook mode\n",
    "    - Script mode \n",
    " - Tensorboard follow up\n",
    "    \n",
    "## 1/ Run a notebook as a batch\n",
    "To run a notebook :  \n",
    "```jupyter nbconvert --to notebook --execute <notebook>```"
   ]
  },
  {
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": [
    "## 2/ Export as a script (better choice)\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": [
    "## 3/ Batch submission\n",
    "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 _batch/full_convolutions_%jobid%.out\n",
    "#OAR --stderr _batch/full_convolutions_%jobid%.err\n",
    "#OAR --project deeplearningshs\n",
Jean-Luc Parouty's avatar
Jean-Luc Parouty committed
    "\n",
    "#---- For 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"
Jean-Luc Parouty's avatar
Jean-Luc Parouty committed
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "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.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}