We highly recommend developers follow our best practices to install MMEditing. However, the whole process is highly customizable. See Customize Installation section for more information.

Best Practices

The following steps work on Linux, Windows, and macOS. If you have already set up a PyTorch environment, no matter using conda or pip, you can start from step 3.

Step 0. Download and install Miniconda from official website.

Step 1. Create a conda environment and activate it

conda create --name mmedit python=3.8 -y
conda activate mmedit

Step 2. Install PyTorch following official instructions, e.g.

  • On GPU platforms:

    conda install pytorch=1.10 torchvision cudatoolkit=11.3 -c pytorch
  • On CPU platforms:

    conda install pytorch=1.10 torchvision cpuonly -c pytorch

Step 3. Install pre-built MMCV using MIM.

pip3 install openmim
mim install mmcv-full==1.5.0

Step 4. Install MMEditing from the source code.

git clone
cd mmediting
pip3 install -e .

Step 5. Verification.

cd ~
python -c "import mmedit; print(mmedit.__version__)"
# Example output: 0.14.0

The installation is successful if the version number is output correctly.

Customize Installation

Version of Dependencies

You may change the version of Python, PyTorch, and MMCV by changing the version numbers in Step 1, 2, and 3, respectively.

Currently, MMEditing works with

Version of CUDA

When installing PyTorch in Step 2, you need to specify the version of CUDA. If you are not clear on which to choose, follow our recommendations:

  1. For Ampere-based NVIDIA GPUs, such as GeForce 30 series and NVIDIA A100, CUDA 11 is a must.

  2. For older NVIDIA GPUs, CUDA 11 is backward compatible, but CUDA 10.2 offers better compatibility and is more lightweight.

Please also make sure the GPU driver satisfies the minimum version requirements. See this table for more information.

Please Note that there is no need to install the complete CUDA toolkit if you follow our best practices because no CUDA code will be compiled. However, if you hope to compile MMCV or other C++/CUDA operators, you need to install the complete CUDA toolkit from NVIDIA’s website, and its version should match the CUDA version of PyTorch, which is the version of cudatoolkit in conda install.

Install without Conda

Though we highly recommend using conda to create environments and install PyTorch, it is viable to install PyTorch only with pip, for example, with the following command,

pip3 install torch torchvision

However, an --extra-index-url or -f option is usually required to specify the CPU / CUDA version. See PyTorch website for more details.

Install without MIM

MMCV contains C++ and CUDA extensions, thus depending on PyTorch in a complex way. MIM solves such dependency automatically and makes installation easier. However, it is not a must.

To install MMCV with pip instead of MIM, please follow MMCV installation guides. This requires manually specifying a find-url based on PyTorch version and its CUDA version.

For example, the following command install mmcv-full built for PyTorch 1.10.x and CUDA 11.3.

pip install mmcv-full -f

On macOS

Pre-built MMCV package is not available for macOS, so you have to build MMCV from the source. Pip will build it automatically during installation, but it requires a C++ compiler. A simple solution is to install Clang with xcode-select --install.

Under such circumstances, MIM is not required and pip install mmcv-full -v can do the job. See MMCV installation guides for more details.

On Google Colab

Online machine learning platform such as Google Colab usually has PyTorch installed. Thus we only need to install MMCV and MMEditing with the following commands.

Step 1. Install pre-built MMCV using MIM.

!pip3 install openmim
!mim install mmcv-full

Step 2. Install MMEditing from the source.

!git clone
%cd mmediting
!pip3 install -e .

Step 3. Verification.

import mmedit
# Example output: 0.13.0

Note: within Jupyter, the exclamation mark ! is used to call external executables and %cd is a IPython magic command to change the current working directory of Python.

Additional Notes

Speed up Installation with Mirror

One can configure conda and pip mirrors to speed up the installation. This step is very practical for users geologically in China.

See the below links (in Chinese) for details:

On -e .

You may be curious about what -e . means when supplied with pip install. Here is the description:

  • -e means editable mode. When import mmedit, modules under the cloned directory are imported. If pip install without -e, pip will copy cloned codes to somewhere like lib/python/site-package. Consequently, modified code under the cloned directory takes no effect unless pip install again. This is particularly convenient for developers. If some codes are modified, new codes will be imported next time without reinstallation.

  • . means code in this directory

You can also use pip -e .[all], which will install more dependencies, especially for pre-commit hooks and unittests.

Read the Docs v: stable
On Read the Docs
Project Home

Free document hosting provided by Read the Docs.