{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "name": "DenseDepth_training", "provenance": [], "collapsed_sections": [], "include_colab_link": true }, "kernelspec": { "name": "python3", "display_name": "Python 3" }, "accelerator": "GPU" }, "cells": [ { "cell_type": "markdown", "metadata": { "id": "view-in-github", "colab_type": "text" }, "source": [ "<a href=\"https://colab.research.google.com/github/pranjaldatta/DenseDepth-Pytorch/blob/master/DenseDepth_training.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" ] }, { "cell_type": "code", "metadata": { "id": "uKwAx1CLhUBi", "colab_type": "code", "colab": {} }, "source": [ "# Cloning the Repository \n", "\n", "!git clone https://github.com/pranjaldatta/DenseDepth-Pytorch.git" ], "execution_count": null, "outputs": [] }, { "cell_type": "code", "metadata": { "id": "Arc9mPZwh2N6", "colab_type": "code", "colab": {} }, "source": [ "# Getting the data \n", "!python DenseDepth-Pytorch/densedepth/download_data.py" ], "execution_count": null, "outputs": [] }, { "cell_type": "code", "metadata": { "id": "ZVpEiIs5hBpM", "colab_type": "code", "colab": {} }, "source": [ "# Mounting drive\n", "from google.colab import drive\n", "drive.mount('/gdrive')\n", "\n", "\n", "!mkdir /gdrive/My\\ Drive/colabdrive/work/densedepth\n", "!mkdir /gdrive/My\\ Drive/colabdrive/work/densedepth/checkpoints\n" ], "execution_count": null, "outputs": [] }, { "cell_type": "code", "metadata": { "id": "-vR1s2EJk4-u", "colab_type": "code", "colab": {} }, "source": [ "!pip install tensorboardX" ], "execution_count": null, "outputs": [] }, { "cell_type": "code", "metadata": { "id": "7bIenkWV3zc8", "colab_type": "code", "colab": {} }, "source": [ "# Prefer using Nvidia T4's or P100 for favourable training times\n", "\n", "\n", "# memory footprint support libraries/code\n", "!ln -sf /opt/bin/nvidia-smi /usr/bin/nvidia-smi\n", "!pip install gputil\n", "!pip install psutil\n", "!pip install humanize\n", "import psutil\n", "import humanize\n", "import os\n", "import GPUtil as GPU\n", "GPUs = GPU.getGPUs()\n", "# XXX: only one GPU on Colab and isn’t guaranteed\n", "gpu = GPUs[0]\n", "def printm():\n", " process = psutil.Process(os.getpid())\n", " print(\"Gen RAM Free: \" + humanize.naturalsize( psutil.virtual_memory().available ), \" | Proc size: \" + humanize.naturalsize( process.memory_info().rss))\n", " print(\"GPU RAM Free: {0:.0f}MB | Used: {1:.0f}MB | Util {2:3.0f}% | Total {3:.0f}MB\".format(gpu.memoryFree, gpu.memoryUsed, gpu.memoryUtil*100, gpu.memoryTotal))\n", "printm()" ], "execution_count": null, "outputs": [] }, { "cell_type": "code", "metadata": { "id": "8tcQU5Nj517I", "colab_type": "code", "colab": {} }, "source": [ "!nvidia-smi" ], "execution_count": null, "outputs": [] }, { "cell_type": "code", "metadata": { "id": "O_iy8bYQj8lW", "colab_type": "code", "colab": {} }, "source": [ "!python DenseDepth-Pytorch/densedepth/train.py --epochs 10 \\\n", " --data \"data/nyu_depth.zip\" \\\n", " --batch 4 \\\n", " --save \"<path to save checkpoints in (prefer drive if using colab)\" \\\n", " --device \"cuda\" \\\n", " --checkpoint \"<path to checkpoint from which to resume training>\"\n", "\n" ], "execution_count": null, "outputs": [] }, { "cell_type": "code", "metadata": { "id": "9qyUbGhia5d6", "colab_type": "code", "colab": {} }, "source": [ "!python DenseDepth-Pytorch/densedepth/test.py --checkpoint \"<path to load weights from\" \\\n", " --device \"cuda\" \\\n", " --data \"DenseDepth-Pytorch/examples/\"\n", " \n", " " ], "execution_count": null, "outputs": [] } ] }