{ "cells": [ { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "view-in-github" }, "source": [ "\"Open" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "Zl6yrjD75Fx7" }, "outputs": [], "source": [ "# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved" ] }, { "cell_type": "markdown", "metadata": { "id": "6XzxTZfKwFNo" }, "source": [ "# Installation\n", "\n", "VISSL installation is simple: we provide pre-built binaries (pip, conda) and also instructions for building from source (pip, conda).\n" ] }, { "cell_type": "markdown", "metadata": { "id": "imQmMr-626YJ" }, "source": [ "## Requirements\n", "\n", "At a high level, project requires following system dependencies.\n", "\n", "- Linux\n", "- Python>=3.6.2 and <3.9\n", "- PyTorch>=1.4\n", "- torchvision (matching PyTorch install)\n", "- CUDA (must be a version supported by the pytorch version)\n", "- OpenCV\n", "\n", "Note our circle-ci runs tests on Pytorch versions 1.6.0 and 1.9.1 and these are our preferred versions. If you are using FSDP using the [fairscale](https://github.com/facebookresearch/fairscale) library, they run their unit tests on Pytorch versions 1.6.0, 1.7.1, and 1.8.1. \n", "\n" ] }, { "cell_type": "markdown", "metadata": { "id": "SP8rIA5U3D-1" }, "source": [ "## Installing VISSL from pre-built binaries\n", "\n", "VISSL provides conda and pip binaries pre-built.\n", "\n" ] }, { "cell_type": "markdown", "metadata": { "id": "D7hyDr_F3MQw" }, "source": [ "### Install VISSL conda package\n", "\n", "This assumes you have conda 10.2.\n", "\n", "```bash\n", "conda create -n vissl python=3.8\n", "conda activate vissl\n", "conda install -c pytorch pytorch=1.7.1 torchvision cudatoolkit=10.2\n", "conda install -c vissl -c iopath -c conda-forge -c pytorch -c defaults apex vissl\n", "```\n", "\n", "For other versions of PyTorch, Python, CUDA, please modify the above instructions with the\n", "desired version. VISSL provides Apex packages for all combinations of pytorch, python and compatible cuda.\n" ] }, { "cell_type": "markdown", "metadata": { "id": "PRMtGG1c3QrY" }, "source": [ "\n", "### Install VISSL pip package\n", "\n", "This example is with pytorch 1.5.1 and cuda 10.1. Please modify the PyTorch version, cuda version and accordingly apex version below for the desired settings.\n", "\n", "- We use `PyTorch=1.5.1` with `CUDA 10.1` in the following instruction (user can chose their desired version).\n", "- There are several ways to install opencv, one possibility is as follows.\n", "- For APEX, we provide pre-built binary built with optimized C++/CUDA extensions provided by APEX.\n", "Note that, for the APEX install, you need to get the versions of CUDA, PyTorch, and Python correct in the URL. We provide APEX versions for all possible combinations of Python, PyTorch, and CUDA. Select the right APEX Wheels if you want a different combination.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "N2q2fEUp3sqP" }, "outputs": [], "source": [ "# Install: PyTorch (we assume 1.5.1 but VISSL works with all PyTorch versions >=1.4)\n", "!pip install torch==1.5.1+cu101 torchvision==0.6.1+cu101 -f https://download.pytorch.org/whl/torch_stable.html\n", "\n", "# install opencv\n", "!pip install opencv-python\n", "\n", "# install apex by checking system settings: cuda version, pytorch version, python version\n", "import sys\n", "import torch\n", "version_str=\"\".join([\n", " f\"py3{sys.version_info.minor}_cu\",\n", " torch.version.cuda.replace(\".\",\"\"),\n", " f\"_pyt{torch.__version__[0:5:2]}\"\n", "])\n", "print(version_str)\n", "\n", "# install apex (pre-compiled with optimizer C++ extensions and CUDA kernels)\n", "!pip install apex -f https://dl.fbaipublicfiles.com/vissl/packaging/apexwheels/{version_str}/download.html\n", "\n", "# install VISSL\n", "!pip install vissl" ] }, { "cell_type": "markdown", "metadata": { "id": "JPhZPxPa3UhL" }, "source": [ "## Installing VISSL from source\n", "The following instructions assume that you have a CUDA version installed and working.\n" ] }, { "cell_type": "markdown", "metadata": { "id": "naGJKTvM3Yon" }, "source": [ "### Install from source in PIP environment\n", "\n", "**Step 1: Create Virtual environment (pip)**\n", "```bash\n", "python3 -m venv ~/venv\n", ". ~/venv/bin/activate\n", "```\n", "\n", "**Step 2: Install PyTorch (pip)**\n", "\n", "```bash\n", "pip install torch==1.7.1+cu101 torchvision==0.8.2+cu101 -f https://download.pytorch.org/whl/torch_stable.html\n", "```\n", "\n", "**Step 3: Install APEX (pip)**\n", "\n", "```bash\n", "pip install apex -f https://dl.fbaipublicfiles.com/vissl/packaging/apexwheels/py37_cu101_pyt171/download.html\n", "```\n", "\n", "**Step 4: Install VISSL**\n", "\n", "```bash\n", "# clone vissl repository\n", "cd $HOME && git clone --recursive https://github.com/facebookresearch/vissl.git && cd $HOME/vissl/\n", "# install vissl dependencies\n", "pip install --progress-bar off -r requirements.txt\n", "pip install opencv-python\n", "# update classy vision install to current main.\n", "pip uninstall -y classy_vision\n", "pip install classy-vision@https://github.com/facebookresearch/ClassyVision/tarball/main\n", "# Update fairscale to commit compatible with vissl main.\n", "!pip uninstall -y fairscale\n", "!pip install fairscale@https://github.com/facebookresearch/fairscale/tarball/df7db85cef7f9c30a5b821007754b96eb1f977b6\n", "# install vissl dev mode (e stands for editable)\n", "pip install -e .[dev]\n", "# verify installation\n", "python -c 'import vissl, apex, cv2'\n", "```\n" ] }, { "cell_type": "markdown", "metadata": { "id": "cdrzFg163bp5" }, "source": [ "### Install from source in Conda environment\n", "\n", "**Step 1: Create Conda environment**\n", "\n", "If you don't have anaconda, [run this bash script to install conda](https://github.com/facebookresearch/vissl/blob/master/docker/common/install_conda.sh).\n", "\n", "```bash\n", "conda create -n vissl_env python=3.7\n", "source activate vissl_env\n", "```\n", "\n", "**Step 2: Install PyTorch (conda)**\n", "\n", "```bash\n", "conda install pytorch torchvision cudatoolkit=10.1 -c pytorch\n", "```\n", "\n", "**Step 3: Install APEX (conda)**\n", "\n", "```bash\n", "conda install -c vissl apex\n", "```\n", "\n", "**Step 4: Install VISSL**\n", "Follow [step4 instructions from the PIP installation](#step-4-install-vissl-from-source)\n", "\n", "That's it! You are now ready to use VISSL.\n" ] }, { "cell_type": "markdown", "metadata": { "id": "u6Fxe3MWxqsI" }, "source": [ "VISSL should be successfuly installed by now and all the dependencies should be available." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "Np6atgoOTPrA" }, "outputs": [], "source": [ "import vissl\n", "import tensorboard\n", "import apex\n", "import torch" ] } ], "metadata": { "accelerator": "GPU", "colab": { "collapsed_sections": [], "include_colab_link": true, "name": "Installation V0.1.6.ipynb", "provenance": [] }, "kernelspec": { "display_name": "Python 3", "name": "python3" } }, "nbformat": 4, "nbformat_minor": 2 }