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. Otherwise, you can follow these steps for the preparation.
Step 0. Download and install Miniconda from the official website.
Step 1. Create a conda environment and activate it.
conda create --name openmmlab python=3.8 -y conda activate openmmlab
Step 2. Install PyTorch following official instructions, e.g.
On GPU platforms:
conda install pytorch torchvision -c pytorch
On CPU platforms:
conda install pytorch torchvision cpuonly -c pytorch
We recommend that users follow our best practices to install MMRazor.
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:
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:
pip install "mmrazor>=1.0.0"