Newer
Older
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<img width=\"800px\" src=\"../fidle/img/00-Fidle-header-01.svg\"></img>\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",
"## 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",
"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>```"
"cell_type": "raw",
"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"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Step 2 - Export as a script (What we're going to do !)\n",
"```jupyter nbconvert --to script <notebook>``` \n",
"To run the script : \n",
"```ipython <script>```"
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"[NbConvertApp] Converting notebook 05-Full-convolutions.ipynb to script\n",
"[NbConvertApp] Writing 11305 bytes to ./run/full_convolutions_B.py\n"
"# ---- This will convert a notebook to a notebook.py script\n",
"jupyter nbconvert --to script --output='./run/full_convolutions_B' '05-Full-convolutions.ipynb'"
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"-rw-r--r-- 1 pjluc pjluc 11305 Jan 21 00:13 ./run/full_convolutions_B.py\n"
"!ls -l ./run/*.py"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Create batch script :"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"%%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",
"# use :\n",
"# OAR -l /nodes=1/core=32,walltime=01:00:00\n",
"# and add a 2>/dev/null to ipython xxx\n",
"\n",
"# ----------------------------------\n",
"# _ _ _\n",
"# | |__ __ _| |_ ___| |__\n",
"# | '_ \\ / _` | __/ __| '_ \\\n",
"# | |_) | (_| | || (__| | | |\n",
"# |_.__/ \\__,_|\\__\\___|_| |_|\n",
"# Full convolutions\n",
"# ----------------------------------\n",
"#\n",
"\n",
"CONDA_ENV=deeplearning2\n",
"RUN_DIR=~/fidle/GTSRB\n",
"\n",
"# ---- Cuda Conda initialization\n",
"#\n",
"echo '------------------------------------------------------------'\n",
"echo \"Start : $0\"\n",
"echo '------------------------------------------------------------'\n",
"#\n",
"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",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"-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"
]
}
],
"source": [
"%%bash\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 (...)"
"<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",
}
},
"nbformat": 4,
"nbformat_minor": 4
}