Registry / ai-ml / openmim

openmim

JSON →
library0.3.9pypypi✓ verified 21d ago

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.

pip install openmim
INSTALL
IMPORT
SIG · OPENMIM
O
openmim
ai-mlpythonv0.3.9
Install
15.0s avg
Import
11ms
Disk
226MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.3.9 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.012s · 219MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 15.0s · import 0.008s · 213MB
226MB installed
● package 226MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

mim
import subprocess subprocess.run(['python', '-m', 'mim', 'command', 'args'])
OpenMMLab's MIM is primarily a command-line interface tool. While it can be invoked directly from the shell as 'mim', using 'python -m mim' programmatically (e.g., via subprocess) ensures the correct Python environment is used. There are no direct Python imports like `from mim import install` for end-user functionality.

This quickstart demonstrates how to use `openmim` programmatically to install an OpenMMLab package (like `mmcv-full`) and download a pretrained model configuration. `mim` handles complex dependencies, including CUDA toolkits for `mmcv-full`. The `python -m mim` invocation is used to ensure compatibility with the current Python environment.

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.')
mim --version
Debug
Known issues
gotchaMixing `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.
fix
Use `mim` for all OpenMMLab package installations and their core dependencies. If `pip` must be used for other parts of the project, ensure `mim` has full control over the OpenMMLab stack.
affects: All versions
gotchaFor 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.
fix
Always invoke MIM using `python -m mim` instead of `mim` directly when executing from scripts or when in doubt about the active Python environment.
affects: < 0.3.1 (less robust)
gotchaUsers 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.
fix
Upgrade to `openmim` version `0.3.6` or newer using `pip install --upgrade openmim`.
affects: < 0.3.6
deprecatedOlder 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.
fix
Upgrade to `openmim` version `0.3.4` or newer to avoid `distutils.version` deprecation warnings.
affects: < 0.3.4
Errors
Common errors & fixes
mim: command not found
After `pip install openmim`, the `mim` executable might not be in your system's PATH, especially in complex Python environments or when the Python site-packages script directory isn't automatically added to PATH.
fix
Use `python -m mim` instead of `mim` directly to explicitly invoke the `mim` module with the correct Python interpreter. Alternatively, ensure the Python environment's script directory is added to your system's PATH.
ModuleNotFoundError: No module named 'aliyunsdkcore'
This error occurs during the installation of `openmim` or its dependencies, specifically `opendatalab` which transitively depends on `aliyunsdkcore`. It often happens due to issues with metadata generation for `aliyunsdkcore` during `pip`'s resolution process.
fix
This issue is often transient or related to specific `pip` versions. Ensure `pip` is up-to-date (`pip install --upgrade pip`). If the problem persists, try installing `aliyunsdkcore` manually first (`pip install aliyun-python-sdk-core`) before installing `openmim`.
The detected CUDA version (X.Y) mismatches the version that was used to compile PyTorch (A.B). Please make sure to use the same CUDA versions.
This critical error arises when installing OpenMMLab packages (like `mmcv`) via `mim install`. It indicates that the CUDA version detected on your system (or in the environment) does not match the CUDA version with which your installed PyTorch was compiled, leading to incompatibility.
fix
Ensure that your PyTorch installation and the system's CUDA toolkit (or the CUDA version specified in your environment) are perfectly aligned. It's often best to install PyTorch with a specific CUDA version first using `conda` or `pip` (e.g., `conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia`), and then use `mim install` for OpenMMLab packages, which will try to find compatible versions. Explicitly set `CUDA_HOME` if needed to prioritize the correct CUDA version.
AttributeError: module 'pkgutil' has no attribute 'ImpImporter'
This error signifies an incompatibility with newer Python versions, specifically Python 3.12. The `pkgutil.ImpImporter` attribute has been deprecated and removed in Python 3.12, and `openmim` (or its underlying dependencies) might be using this deprecated functionality.
fix
Downgrade your Python environment to a compatible version, such as Python 3.8, 3.9, or 3.10. Check the OpenMMLab documentation for the officially supported Python versions for your specific OpenMMLab project.
ModuleNotFoundError: No module named 'mmcv'
This error occurs when you try to import an OpenMMLab package (like `mmpretrain` or `mmdet`) after installing it with `mim install`, but `mmcv` (a core dependency) was not installed correctly or is not accessible in the current Python environment. This can be caused by `pip` version conflicts (e.g., with `pip>=24.1`) or mixing `mim install` with direct `pip install` for core dependencies.
fix
Ensure you are using `mim` exclusively for OpenMMLab package installations and their core dependencies. If using `pip` for other packages, ensure `mim` has full control over the OpenMMLab stack. If `pip` version is an issue, consider downgrading `pip` to a known compatible version (e.g., `pip<=24.0`) before running `mim install`. Always use `python -m mim install <package>` to ensure the correct environment.
Upgrade
Version history
0.3.9latest on PyPI · released Jun 28, 2023
Audit
Dependencies

No dependency data recorded yet.

Agent activity
26 hits · last 30 days
node
22
Resources