[Docs] Build from source with Python 3.12 + PyTorch 2.8 + CUDA 12.9 is easy and works on Linux
📚 The doc issue
Hey there,
to anyone looking for a setup with a more recent PyTorch version, I just wanted to document that the following versions did work for me on Linux. I did not exhaustively test the install but a simple training with mmdet 3 ran just fine for a few iterations :)
# env
conda create --name my_env python=3.12
conda activate my_env
pip install torch==2.8.0+cu129 torchvision==0.23.0+cu129 --index-url https://download.pytorch.org/whl/cu129
conda install -c nvidia cuda==12.9
# mmcv from source: https://mmcv.readthedocs.io/en/latest/get_started/build.html
# gcc (Debian 12.2.0-14+deb12u1) 12.2.0
git clone https://github.com/open-mmlab/mmcv.git
cd mmcv
pip install -r requirements/optional.txt
pip install -e . -v
Hope this helps, will update when properly verified.
Suggest a potential alternative/fix
No response
I am trying to do the same on my Windows 64 machine with PyTorch 2.8.0 + CUDA 12.9. But. when I run "pip install -e . -v", I get the following error.
(train) c:\qlabRoot\projects\VtTrain\mmcv>pip install -e . -v
Using pip 25.2 from C:\Users\jaqu\anaconda3\envs\train\Lib\site-packages\pip (python 3.13)
Obtaining file:///C:/qlabRoot/projects/VtTrain/mmcv
Running command python setup.py egg_info
C:\qlabRoot\projects\VtTrain\mmcv\setup.py:5: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
from pkg_resources import DistributionNotFound, get_distribution, parse_version
Traceback (most recent call last):
File "<string>", line 2, in <module>
exec(compile('''
~~~~^^^^^^^^^^^^
# This is <pip-setuptools-caller> -- a caller that pip uses to run setup.py
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...<32 lines>...
exec(compile(setup_py_code, filename, "exec"))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
''' % ('C:\\qlabRoot\\projects\\VtTrain\\mmcv\\setup.py',), "<pip-setuptools-caller>", "exec"))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<pip-setuptools-caller>", line 35, in <module>
File "C:\qlabRoot\projects\VtTrain\mmcv\setup.py", line 485, in <module>
version=get_version(),
~~~~~~~~~~~^^
File "C:\qlabRoot\projects\VtTrain\mmcv\setup.py", line 47, in get_version
return locals()['__version__']
~~~~~~~~^^^^^^^^^^^^^^^
KeyError: '__version__'
error: subprocess-exited-with-error
Unfortunately, I have no experience with mmcv on Windows 😅
I used Python 3.12 but that should not be the problem. I suspect something else.
Have you checked the things mentioned here?
https://mmcv.readthedocs.io/en/latest/get_started/build.html#build-on-windows
In particular "6. Set up MSVC compiler"?
They mention that only utf-8 is recognized and you should set your System to English.
Just a wild guess 😄 Hope it helps, good luck!
will it work with mmdetection especially for training mask-rcnn ImportError: /home/darklynx/miniconda3/envs/mmdet_env/lib/python3.10/site-packages/mmcv/_ext.cpython-310-x86_64-linux-gnu.so: undefined symbol: _ZN3c105ErrorC2ENS_14SourceLocationESs just no idea how to fix that
Yes, it will work but you have to apply this change in mmdet to install it: https://github.com/open-mmlab/mmcv/issues/3096#issuecomment-2116951999
However, before you install mmdet, you should check your mmcv installation. Did you run python .dev_scripts/check_installation.py as described here (step 6)? Looks like your compilation did not work correctly.
https://mmcv.readthedocs.io/en/latest/get_started/build.html#build-on-linux
After digging further into the KeyError: '__version__' error I reported above, I found out that it is related to the changes in Python 3.13. Specifically, it pertains to PEP 667 changes made in Python 3.13 as discussed here.
In case it helps others running into this issue: Modifying the get_version function in mmcv/setup.py as follows fixed it for me:
def get_version():
version_file = 'mmcv/version.py'
d = {}
with open(version_file, encoding='utf-8') as f:
exec(compile(f.read(), version_file, 'exec'), globals(), d)
return d['__version__']
P.S. I wanted to submit a pull request for this change, but, ran into an issue elsewhere unrelated to this.
Have you try python .dev_scripts/check_installation.py ?
I followed this (for this exact example and with cuda 12.8, python 3.10 as well). To run mmdet3d, should I also be installing mmdet before mmdet3d as per instructions from mmdet3d docs? Because when I do that, mmdet installation fails because it needs mmcv <2.2.0 and same for mmdet3d.
Hey @azztt, to install (or use) mmdet you have to modify,
mmdetection/mmdet/__init__.pyand manually changemmcv_maximum_version = '2.2.0'tommcv_maximum_version = '2.2.1'
because they have a strict < assert check in place. I have no experience with mmdet3d, but you might have to do something similar there if you run into errors. Hope this helps :)
Unfortunately, all the OpenMMLab projects seem to be abandoned. I don't have much time right now but I'm considering a more general solution to all of these problems in the near future.
Hey, thanks for reply. Does this mean I'll need to build both of them from source as well? If yes, I'll try that and let post the results here.
Thanks
Assuming you have sucessfully installed mmcv 2.2.0, you should be able to simply:
git clone https://github.com/open-mmlab/mmdetection.git- apply the change from above in
mmdetection/mmdet/__init__.py pip install ./mmdetectionorpip install -e ./mmdetection(depending on your need)- now install mmdet3d
But as I mentioned, I have no experience with mmdet3d and it might well be that you have to fix more things.
I successfully installed the MMENGINE and MMCV from the source. Then I validate the installation of MMCV and meet the following errors:
File "/home/mmlab/mmcv/.dev_scripts/check_installation.py", line 4, in
My installation environment is: Python 3.12, Pytorch 2.6.0, CUDA 12.4.
What can I do?
Hm, I have not tested these versions. But you can check if there is a file like _ext.cpython-312-x86_64-linux-gnu.so (might have a different name on you system) in the mmcv/mmcv folder (same level as mmcv/mmcv/utils folder etc.).
If this is not the case, maybe try different versions or carefully re-read the docs I linked above and re-compile mmcv.
Other people have the same problem btw (and a potential solution): https://github.com/open-mmlab/mmcv/issues/3310
Honestly, I get the impression that the original maintainers of OpenMMLab projects aren't active any more and the project setups haven't been updated for a long time and hence keep failing while trying to build with newer versions of PyTorch, Cuda, Python etc. I found the following where people seem to be more interested in maintaining them. https://github.com/VBTI-development
Yes, I've seen that. The effort is clearly honorable, but I'm not sure if this is the way forward. Open-mmlab was a research project, OneDL seems to be a product.
Now I successfully installed the MMENGINE and MMCV from the source, and MMDETECTION using the pip.
I create a Conda virtual installation environment as follows: python 3.10, pytorch 2.6.0, cuda 12.4.
MMENGINE is downloaded from the main branch and can be installed directly via 'pip install -e . -v'.
MMCV is downloaded from the main branch and installed via 'pip install -e . --no-build-isolation'.
MMDETECTION is installed via 'pip install mmdet'. Before I tried to install it from the source, but I still met the error of 'No module named torch' even torch is installed already.
Many thanks.
Hello, according to your configuration compilation, I still haven't compiled successfully (ModuleNotFoundError: No module named 'mmcv._ext')
Hello, according to your configuration compilation, I still haven't compiled successfully (ModuleNotFoundError: No module named 'mmcv._ext')
Hi guys, I am able to build mmcv and mmdet, this is my env
Python: 3.10 CUDA: 12.9 PyTorch: 2.9.1
You guys can checkout this comment for more info. Tks.