# Installation ## Prerequisites In this section we demonstrate how to prepare an environment with PyTorch. MMRazor works on Linux, Windows and macOS. It requires Python 3.6+, CUDA 9.2+ and PyTorch 1.8+. **Note:** If you are experienced with PyTorch and have already installed it, just skip this part and jump to the [next section](##installation). Otherwise, you can follow these steps for the preparation. **Step 0.** Download and install Miniconda from the [official website](https://docs.conda.io/en/latest/miniconda.html). **Step 1.** Create a conda environment and activate it. ```shell conda create --name openmmlab python=3.8 -y conda activate openmmlab ``` **Step 2.** Install PyTorch following [official instructions](https://pytorch.org/get-started/locally/), e.g. On GPU platforms: ```shell conda install pytorch torchvision -c pytorch ``` On CPU platforms: ```shell conda install pytorch torchvision cpuonly -c pytorch ``` ## Installation We recommend that users follow our best practices to install MMRazor. ### Best Practices **Step 0.** Install [MMCV](https://github.com/open-mmlab/mmcv) using [MIM](https://github.com/open-mmlab/mim). ```shell pip install -U openmim mim install mmengine mim install "mmcv>=2.0.0" ``` **Step 1.** Install MMRazor. Case a: If you develop and run mmrazor directly, install it from source: ```shell git clone -b main https://github.com/open-mmlab/mmrazor.git cd mmrazor pip install -v -e . # '-v' means verbose, or more output # '-e' means installing a project in editable mode, # thus any local modifications made to the code will take effect without reinstallation. ``` Case b: If you use mmrazor as a dependency or third-party package, install it with pip: ```shell pip install "mmrazor>=1.0.0" ```