open-mmlab / mmcv

OpenMMLab Computer Vision Foundation
https://mmcv.readthedocs.io/en/latest/
Apache License 2.0
5.88k stars 1.64k forks source link

python setup.py install not working anymore for install mmcv-full #767

Closed hubutui closed 3 years ago

hubutui commented 3 years ago

I fail to build mmcv from version 1.2.2 with cuda support. compile step:

_CUDA_ARCH_LIST="5.2;5.3;6.0;6.1;6.2;7.0;7.0+PTX;7.2;7.2+PTX;7.5;7.5+PTX;8.0;8.0+PTX;8.6;8.6+PTX"
TORCH_CUDA_ARCH_LIST=${_CUDA_ARCH_LIST} \
MMCV_WITH_OPS=1 FORCE_CUDA=1 python setup.py build
python setup.py install --root="${pkgdir}" --optimize=1 --skip-build

most related log output:

==> Starting package_python-mmcv-full()...
WARNING: The pip package is not available, falling back to EasyInstall for handling setup_requires/test_requires; this is deprecated and will be removed in a future version.
No CUDA runtime is found, using CUDA_HOME='/opt/cuda'
running install
running install_lib
warning: install_lib: 'build/lib' does not exist -- no Python modules to install

Then my finnal site-packages tree looks:

/usr/lib/python3.9/site-packages/mmcv-1.2.4-py3.9.egg-info/
├── dependency_links.txt
├── not-zip-safe
├── PKG-INFO
├── requires.txt
├── SOURCES.txt
└── top_level.txt

0 directories, 6 files

nothing is installed.

check the complete build log for 1.2.2 here, and 1.2.3 here, and 1.2.4 here

Questions:

  1. python setup.py install not working anymore for install mmcv-full?
  2. if true, which command I should use to create a pkg? python setup.py bdist_wheel to build the wheel file and install it?

BTW, I could create mmcv pkg without cuda using the above compile steps with no errors.

ycxioooong commented 3 years ago

what's your PyTorch version? Is it a cpu version of pytorch or a gpu one?

hubutui commented 3 years ago

@ycxioooong I maintain python-mmcv and python-mmcv-full in ArchLinuxCN repo for ArchLinux. I build both cpu and gpu version of mmcv for ArchLinux. The pytorch for ArchLinux is always the latest release, for now, it's 1.7.1.

ycxioooong commented 3 years ago

From other related issues, I feel that it may be caused by a mismatched PyTorch version (GPU/CPU, cuda version, etc) or a mismatched torchvision. So I think you may first check your PyTorch version and see if cuda is available:

import torch
print(torch.__version__, torch.cuda.is_available())
hubutui commented 3 years ago

It's building in a chroot env without a GPU. I have set FORCE_CUDA=1 and TORCH_CUDA_ARCH_LIST, check the build script here, build() function for compiling, package_python-mmcv() for creating python-mmcv, and package_python-mmcv-full() for creating python-mmcv-full.

hubutui commented 3 years ago

I figure out something. It seems that when I run

FORCE_CUDA=1 \
TORCH_CUDA_ARCH_LIST="5.2;5.3;6.0;6.1;6.2;7.0;7.0+PTX;7.2;7.2+PTX;7.5;7.5+PTX;8.0;8.0+PTX;8.6;8.6+PTX" \
python setup.py build

it only runs build_ext, not build_py, so the pure python module is missing, then I install the package with

python setup.py install --root="${pkgdir}" --optimize=1 --skip-build

we usually use --skip-build because we don't wanna compile the source again. add python setup.py build_py to build stage or remove --skip-build might fix it.

ycxioooong commented 3 years ago

Cool, thanks for sharing the information.