MIM (OpenMMLab Install Manager)
MIM is the official command-line utility for managing OpenMMLab packages. It simplifies the installation of complex deep learning libraries, especially those with specific CUDA and PyTorch dependencies, by providing a unified interface for installation, downloading models, and dataset management. It aims to reduce common installation pitfalls for OpenMMLab projects. The current version is 0.3.10, and it generally releases new versions every 1-2 months.
Warnings
- gotcha Mixing `mim install` with direct `pip install` for core OpenMMLab dependencies (e.g., `mmcv`, `mmengine`) can lead to version conflicts or broken installations. It's recommended to let `mim` manage these core packages exclusively.
- gotcha For environments with multiple Python installations or complex PATH settings, using `python -m mim` is more reliable than just `mim` to ensure the correct Python interpreter and associated environment are used for the installation. This pattern was officially supported since v0.3.1.
- gotcha Users on `openmim` versions older than `0.3.6` might encounter an `AssertionError` during initial setup due to an issue with `pip` and `setuptools` import order.
- deprecated Older versions of `openmim` used `distutils.version` internally, which has been deprecated in Python. While this might not directly break user code, it could lead to warnings from the Python interpreter.
Install
-
pip install openmim
Imports
- mim
import subprocess subprocess.run(['python', '-m', 'mim', 'command', 'args'])
Quickstart
import subprocess
import sys
# Install a core OpenMMLab package, e.g., mmcv-full (with CUDA support)
print('Installing mmcv-full using mim...')
install_cmd = [sys.executable, '-m', 'mim', 'install', 'mmcv-full']
result = subprocess.run(install_cmd, capture_output=True, text=True)
print('STDOUT:', result.stdout)
print('STDERR:', result.stderr)
if result.returncode == 0:
print('mmcv-full installed successfully.')
else:
print('Failed to install mmcv-full.')
# You can also download a pretrained model
print('\nDownloading a MMYOLO model using mim...')
download_cmd = [sys.executable, '-m', 'mim', 'download', 'mmyolo', '--config', 'yolov8_s_syncbn_fast_8xb16-500e_coco', '--dest', '.']
result = subprocess.run(download_cmd, capture_output=True, text=True)
print('STDOUT:', result.stdout)
print('STDERR:', result.stderr)
if result.returncode == 0:
print('Model downloaded successfully.')
else:
print('Failed to download model.')