{"cells":[{"cell_type":"markdown","id":"856bf300","metadata":{"id":"856bf300"},"source":["<a href=\"https://colab.research.google.com/github/open-mmlab/mmselfsup/blob/master/demo/mmselfsup_colab_tutorial.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"]},{"cell_type":"markdown","id":"a2505b44","metadata":{"id":"a2505b44"},"source":["# MMSelfSup Tutorial\n","In this tutorial, we will introduce the following content:\n","\n","- How to install MMSelfSup\n","- How to train algorithms in MMSelfSup\n","- How to train downstream tasks\n","\n","If you have any other questions, welcome to report issues."]},{"cell_type":"markdown","id":"2a78b9a6","metadata":{"id":"2a78b9a6"},"source":["## How to install MMSelfSup\n","\n","Before using MMSelfSup, we need to prepare the environment with the following steps:\n","\n","1. Install Python, CUDA, C/C++ compiler and git\n","2. Install PyTorch (CUDA version)\n","3. Install dependent codebase (mmengine, mmcv, mmcls)\n","4. Clone mmselfsup source code from GitHub and install it\n","\n","Because this tutorial is on Google Colab and all necessary packages have been installed, we can skip the first two steps."]},{"cell_type":"code","execution_count":1,"id":"4edc9682","metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":18,"status":"ok","timestamp":1662048513424,"user":{"displayName":"qin ren","userId":"07205769677379266243"},"user_tz":-480},"id":"4edc9682","outputId":"b9f96ef5-96dc-4a26-850c-b42d80586e38"},"outputs":[{"name":"stdout","output_type":"stream","text":["nvcc: NVIDIA (R) Cuda compiler driver\n","Copyright (c) 2005-2020 NVIDIA Corporation\n","Built on Mon_Oct_12_20:09:46_PDT_2020\n","Cuda compilation tools, release 11.1, V11.1.105\n","Build cuda_11.1.TC455_06.29190527_0\n"]}],"source":["# Check nvcc version\n","!nvcc -V"]},{"cell_type":"code","execution_count":2,"id":"f6c86477","metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":11,"status":"ok","timestamp":1662048513425,"user":{"displayName":"qin ren","userId":"07205769677379266243"},"user_tz":-480},"id":"f6c86477","outputId":"4e73eded-7146-44a9-c90b-b4fb4f7cb055"},"outputs":[{"name":"stdout","output_type":"stream","text":["gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0\n","Copyright (C) 2017 Free Software Foundation, Inc.\n","This is free software; see the source for copying conditions. There is NO\n","warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n","\n"]}],"source":["# Check GCC version\n","!gcc --version"]},{"cell_type":"code","execution_count":3,"id":"4d45e19e","metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":2046,"status":"ok","timestamp":1662048515465,"user":{"displayName":"qin ren","userId":"07205769677379266243"},"user_tz":-480},"id":"4d45e19e","outputId":"049a158c-9471-4631-a43a-f24180bf55da"},"outputs":[{"name":"stdout","output_type":"stream","text":["1.12.1+cu113\n","True\n"]}],"source":["# Check PyTorch installation\n","import torch, torchvision\n","print(torch.__version__)\n","print(torch.cuda.is_available())"]},{"cell_type":"markdown","id":"d8b2afc9","metadata":{"id":"d8b2afc9"},"source":["### Install MMEngine and MMCV\n","\n","MMCV is the basic package of all OpenMMLab packages. We have pre-built wheels on Linux, so we can download and install them directly.\n","\n","Please pay attention to PyTorch and CUDA versions to match the wheel.\n","\n","In the above steps, we have checked the version of PyTorch and CUDA, and they are 1.10.2 and 11.3 respectively, so we need to choose the corresponding wheel.\n","\n","In addition, we can also install the full version of mmcv (mmcv-full). It includes full features and various CUDA ops out of the box, but needs a longer time to build."]},{"cell_type":"markdown","id":"12c97bbd","metadata":{"id":"12c97bbd"},"source":["MIM is recommended: https://github.com/open-mmlab/mim"]},{"cell_type":"code","execution_count":4,"id":"ac1462fd","metadata":{"colab":{"base_uri":"https://localhost:8