Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] c++17 error in mmdetection installation step while following the current installation guide #2638

Open
3 tasks done
Kaeseknacker opened this issue Jan 11, 2024 · 2 comments

Comments

@Kaeseknacker
Copy link

Kaeseknacker commented Jan 11, 2024

Checklist

  • I have searched related issues but cannot get the expected help.
  • 2. I have read the FAQ documentation but cannot get the expected help.
  • 3. The bug has not been fixed in the latest version.

Describe the bug

I get a c++17 error in this step (from your current installation guide: https://mmdeploy.readthedocs.io/en/latest/get_started.html#installation):

# clone mmdetection repo. We have to use the config file to build PyTorch nn module
git clone -b 3.x https://github.com/open-mmlab/mmdetection.git
cd mmdetection
mim install -v -e .

ERROR:

[...]
from ./mmcv/ops/csrc/pytorch/active_rotated_filter.cpp:5:
  /home/spraul/miniconda3/envs/mmdeploy_cu118/lib/python3.8/site-packages/torch/include/ATen/ATen.h:4:2: error: #error C++17 or later compatible compiler is required to use ATen.
      4 | #error C++17 or later compatible compiler is required to use ATen.
[...]

I found some related issues:
#2529
open-mmlab/mmcv#2860
But I don't know how to fix it in my case.
mmdeploy/setup.py has no line where I can insert

extra_compile_args['cxx'] = ['-std=c++17']

Also after reading this PR open-mmlab/mmcv#2865 I thought this c++17 issue is fixed with mmcv 2.1.0.
I use mmcv 2.1.0 in my environment.

Any suggestion how to fix this?

Reproduction

These are my complete installation commands:

conda create --name mmdeploy_cu118 python=3.8 -y
conda activate mmdeploy_cu118
conda install pytorch==2.1.2 torchvision==0.16.2 torchaudio==2.1.2 pytorch-cuda=11.8 -c pytorch -c nvidia
pip install -U openmim
mim install mmengine
mim install "mmcv>=2.0.0rc2"
pip install mmdeploy==1.3.1
pip install mmdeploy-runtime-gpu==1.3.1
cd ~/lib/TensorRT/TensorRT_8.2.4.2.Linux.x86_64-gnu.cuda-11.4.cudnn8.2-2/TensorRT_8.2.4.2.Linux.x86_64-gnu.cuda-11.4.cudnn8.2-2/python/
pip install ./tensorrt-8.2.4.2-cp38-none-linux_x86_64.whl 
cd -
. set_mmdeploy_cu118_paths.sh
pip install pycuda
pip install onnxruntime-gpu==1.8.1
git clone -b main https://github.com/open-mmlab/mmdeploy.git mmdeploy_cu118
cd mmdetection_cu118/
mim install -v -e .

Error occurs while trying to install mmdetection.

Environment

01/11 17:11:09 - mmengine - INFO - 

01/11 17:11:09 - mmengine - INFO - **********Environmental information**********
01/11 17:11:10 - mmengine - INFO - sys.platform: linux
01/11 17:11:10 - mmengine - INFO - Python: 3.8.18 (default, Sep 11 2023, 13:40:15) [GCC 11.2.0]
01/11 17:11:10 - mmengine - INFO - CUDA available: True
01/11 17:11:10 - mmengine - INFO - numpy_random_seed: 2147483648
01/11 17:11:10 - mmengine - INFO - GPU 0: NVIDIA GeForce RTX 2070 SUPER
01/11 17:11:10 - mmengine - INFO - CUDA_HOME: /home/spraul/Fraunhofer-IOSB/packy-cache/vid-public/cuda/cuda_11.8.0_520.61.05_linux/cuda_11.8.0_520.61.05_linux
01/11 17:11:10 - mmengine - INFO - NVCC: Cuda compilation tools, release 11.8, V11.8.89
01/11 17:11:10 - mmengine - INFO - GCC: gcc (Debian 10.2.1-6) 10.2.1 20210110
01/11 17:11:10 - mmengine - INFO - PyTorch: 2.1.2
01/11 17:11:10 - mmengine - INFO - PyTorch compiling details: PyTorch built with:
  - GCC 9.3
  - C++ Version: 201703
  - Intel(R) oneAPI Math Kernel Library Version 2023.1-Product Build 20230303 for Intel(R) 64 architecture applications
  - Intel(R) MKL-DNN v3.1.1 (Git Hash 64f6bcbcbab628e96f33a62c3e975f8535a7bde4)
  - OpenMP 201511 (a.k.a. OpenMP 4.5)
  - LAPACK is enabled (usually provided by MKL)
  - NNPACK is enabled
  - CPU capability usage: AVX2
  - CUDA Runtime 11.8
  - NVCC architecture flags: -gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_61,code=sm_61;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_75,code=sm_75;-gencode;arch=compute_80,code=sm_80;-gencode;arch=compute_86,code=sm_86;-gencode;arch=compute_37,code=sm_37;-gencode;arch=compute_90,code=sm_90;-gencode;arch=compute_37,code=compute_37
  - CuDNN 8.7
  - Magma 2.6.1
  - Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CUDA_VERSION=11.8, CUDNN_VERSION=8.7.0, CXX_COMPILER=/opt/rh/devtoolset-9/root/usr/bin/c++, CXX_FLAGS= -D_GLIBCXX_USE_CXX11_ABI=0 -fabi-version=11 -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -DNDEBUG -DUSE_KINETO -DLIBKINETO_NOROCTRACER -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -O2 -fPIC -Wall -Wextra -Werror=return-type -Werror=non-virtual-dtor -Werror=bool-operation -Wnarrowing -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-unused-parameter -Wno-unused-function -Wno-unused-result -Wno-strict-overflow -Wno-strict-aliasing -Wno-stringop-overflow -Wno-psabi -Wno-error=pedantic -Wno-error=old-style-cast -Wno-invalid-partial-specialization -Wno-unused-private-field -Wno-aligned-allocation-unavailable -Wno-missing-braces -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -Werror=cast-function-type -Wno-stringop-overflow, LAPACK_INFO=mkl, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, TORCH_DISABLE_GPU_ASSERTS=ON, TORCH_VERSION=2.1.2, USE_CUDA=ON, USE_CUDNN=ON, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=ON, USE_NNPACK=ON, USE_OPENMP=ON, USE_ROCM=OFF, 

01/11 17:11:10 - mmengine - INFO - TorchVision: 0.16.2
01/11 17:11:10 - mmengine - INFO - OpenCV: 4.9.0
01/11 17:11:10 - mmengine - INFO - MMEngine: 0.10.2
01/11 17:11:10 - mmengine - INFO - MMCV: 2.1.0
01/11 17:11:10 - mmengine - INFO - MMCV Compiler: GCC 9.3
01/11 17:11:10 - mmengine - INFO - MMCV CUDA Compiler: 11.8
01/11 17:11:10 - mmengine - INFO - MMDeploy: 1.3.1+bc75c9d
01/11 17:11:10 - mmengine - INFO - 

01/11 17:11:10 - mmengine - INFO - **********Backend information**********
01/11 17:11:10 - mmengine - INFO - tensorrt:	8.2.4.2
01/11 17:11:10 - mmengine - INFO - tensorrt custom ops:	Available
01/11 17:11:10 - mmengine - INFO - ONNXRuntime:	None
01/11 17:11:10 - mmengine - INFO - ONNXRuntime-gpu:	1.8.1
01/11 17:11:10 - mmengine - INFO - ONNXRuntime custom ops:	Available
01/11 17:11:10 - mmengine - INFO - pplnn:	None
01/11 17:11:10 - mmengine - INFO - ncnn:	None
01/11 17:11:10 - mmengine - INFO - snpe:	None
01/11 17:11:10 - mmengine - INFO - openvino:	None
01/11 17:11:10 - mmengine - INFO - torchscript:	2.1.2
01/11 17:11:10 - mmengine - INFO - torchscript custom ops:	NotAvailable
01/11 17:11:10 - mmengine - INFO - rknn-toolkit:	None
01/11 17:11:10 - mmengine - INFO - rknn-toolkit2:	None
01/11 17:11:10 - mmengine - INFO - ascend:	None
01/11 17:11:10 - mmengine - INFO - coreml:	None
01/11 17:11:10 - mmengine - INFO - tvm:	None
01/11 17:11:10 - mmengine - INFO - vacc:	None
01/11 17:11:10 - mmengine - INFO - 

01/11 17:11:10 - mmengine - INFO - **********Codebase information**********
01/11 17:11:10 - mmengine - INFO - mmdet:	None
01/11 17:11:10 - mmengine - INFO - mmseg:	None
01/11 17:11:10 - mmengine - INFO - mmpretrain:	None
01/11 17:11:10 - mmengine - INFO - mmocr:	None
01/11 17:11:10 - mmengine - INFO - mmagic:	None
01/11 17:11:10 - mmengine - INFO - mmdet3d:	None
01/11 17:11:10 - mmengine - INFO - mmpose:	None
01/11 17:11:10 - mmengine - INFO - mmrotate:	None
01/11 17:11:10 - mmengine - INFO - mmaction:	None
01/11 17:11:10 - mmengine - INFO - mmrazor:	None
01/11 17:11:10 - mmengine - INFO - mmyolo:	None

Error traceback

[...]
  gcc -pthread -B /home/spraul/miniconda3/envs/mmdeploy_cu118/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DMMCV_WITH_CUDA -I/tmp/pip-install-364fs8ik/mmcv_ce57bb2421164066921883ae873dcad6/mmcv/ops/csrc/pytorch -I/tmp/pip-install-364fs8ik/mmcv_ce57bb2421164066921883ae873dcad6/mmcv/ops/csrc/common -I/tmp/pip-install-364fs8ik/mmcv_ce57bb2421164066921883ae873dcad6/mmcv/ops/csrc/common/cuda -I/home/spraul/miniconda3/envs/mmdeploy_cu118/lib/python3.8/site-packages/torch/include -I/home/spraul/miniconda3/envs/mmdeploy_cu118/lib/python3.8/site-packages/torch/include/torch/csrc/api/include -I/home/spraul/miniconda3/envs/mmdeploy_cu118/lib/python3.8/site-packages/torch/include/TH -I/home/spraul/miniconda3/envs/mmdeploy_cu118/lib/python3.8/site-packages/torch/include/THC -I/home/spraul/Fraunhofer-IOSB/packy-cache/vid-public/cuda/cuda_11.8.0_520.61.05_linux/cuda_11.8.0_520.61.05_linux/include -I/home/spraul/miniconda3/envs/mmdeploy_cu118/include/python3.8 -c ./mmcv/ops/csrc/pytorch/active_rotated_filter.cpp -o build/temp.linux-x86_64-3.8/./mmcv/ops/csrc/pytorch/active_rotated_filter.o -std=c++14 -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE=\"_gcc\" -DPYBIND11_STDLIB=\"_libstdcpp\" -DPYBIND11_BUILD_ABI=\"_cxxabi1011\" -DTORCH_EXTENSION_NAME=_ext -D_GLIBCXX_USE_CXX11_ABI=0
  cc1plus: warning: command-line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
  In file included from /home/spraul/miniconda3/envs/mmdeploy_cu118/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/types.h:3,
                   from /tmp/pip-install-364fs8ik/mmcv_ce57bb2421164066921883ae873dcad6/mmcv/ops/csrc/common/pytorch_cpp_helper.hpp:3,
                   from ./mmcv/ops/csrc/pytorch/active_rotated_filter.cpp:5:
  /home/spraul/miniconda3/envs/mmdeploy_cu118/lib/python3.8/site-packages/torch/include/ATen/ATen.h:4:2: error: #error C++17 or later compatible compiler is required to use ATen.
      4 | #error C++17 or later compatible compiler is required to use ATen.
        |  ^~~~~
  In file included from /home/spraul/miniconda3/envs/mmdeploy_cu118/lib/python3.8/site-packages/torch/include/c10/util/string_view.h:4,
                   from /home/spraul/miniconda3/envs/mmdeploy_cu118/lib/python3.8/site-packages/torch/include/c10/util/StringUtil.h:6,
                   from /home/spraul/miniconda3/envs/mmdeploy_cu118/lib/python3.8/site-packages/torch/include/c10/util/Exception.h:5,
                   from /home/spraul/miniconda3/envs/mmdeploy_cu118/lib/python3.8/site-packages/torch/include/ATen/core/Generator.h:11,
                   from /home/spraul/miniconda3/envs/mmdeploy_cu118/lib/python3.8/site-packages/torch/include/ATen/CPUGeneratorImpl.h:3,
                   from /home/spraul/miniconda3/envs/mmdeploy_cu118/lib/python3.8/site-packages/torch/include/ATen/Context.h:3,
                   from /home/spraul/miniconda3/envs/mmdeploy_cu118/lib/python3.8/site-packages/torch/include/ATen/ATen.h:7,
                   from /home/spraul/miniconda3/envs/mmdeploy_cu118/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/types.h:3,
                   from /tmp/pip-install-364fs8ik/mmcv_ce57bb2421164066921883ae873dcad6/mmcv/ops/csrc/common/pytorch_cpp_helper.hpp:3,
                   from ./mmcv/ops/csrc/pytorch/active_rotated_filter.cpp:5:
  /home/spraul/miniconda3/envs/mmdeploy_cu118/lib/python3.8/site-packages/torch/include/c10/util/C++17.h:27:2: error: #error You need C++17 to compile PyTorch
     27 | #error You need C++17 to compile PyTorch
        |  ^~~~~

[...]  

  /home/spraul/miniconda3/envs/mmdeploy_cu118/lib/python3.8/site-packages/torch/include/ATen/core/boxing/impl/make_boxed_from_unboxed_functor.h:215:10: warning: ‘if constexpr’ only available with ‘-std=c++17’ or ‘-std=gnu++17’
    215 |       if constexpr(guts::typelist::contains<supported_primitive_arg_types, T>::value) {
        |          ^~~~~~~~~
  /home/spraul/miniconda3/envs/mmdeploy_cu118/lib/python3.8/site-packages/torch/include/ATen/core/boxing/impl/make_boxed_from_unboxed_functor.h: In static member function ‘static void c10::impl::make_boxed_from_unboxed_functor<KernelFunctor, AllowDeprecatedTypes>::call(c10::OperatorKernel*, const c10::OperatorHandle&, c10::DispatchKeySet, c10::Stack*)’:
  /home/spraul/miniconda3/envs/mmdeploy_cu118/lib/python3.8/site-packages/torch/include/ATen/core/boxing/impl/make_boxed_from_unboxed_functor.h:575:10: warning: ‘if constexpr’ only available with ‘-std=c++17’ or ‘-std=gnu++17’
    575 |       if constexpr (has_outputs) {
        |          ^~~~~~~~~
  In file included from /home/spraul/miniconda3/envs/mmdeploy_cu118/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/types.h:12,
                   from /tmp/pip-install-364fs8ik/mmcv_ce57bb2421164066921883ae873dcad6/mmcv/ops/csrc/common/pytorch_cpp_helper.hpp:3,
                   from ./mmcv/ops/csrc/pytorch/active_rotated_filter.cpp:5:
  /home/spraul/miniconda3/envs/mmdeploy_cu118/lib/python3.8/site-packages/torch/include/ATen/core/dispatch/Dispatcher.h: In static member function ‘static Return c10::Dispatcher::callWithDispatchKeySlowPath(const c10::TypedOperatorHandle<Return(Args ...)>&, at::StepCallbacks&, c10::DispatchKeySet, const c10::KernelFunction&, Args ...)’:
  /home/spraul/miniconda3/envs/mmdeploy_cu118/lib/python3.8/site-packages/torch/include/ATen/core/dispatch/Dispatcher.h:597:6: warning: ‘if constexpr’ only available with ‘-std=c++17’ or ‘-std=gnu++17’
    597 |   if constexpr (num_boxed_args != 0) {
        |      ^~~~~~~~~
  error: command '/usr/bin/gcc' failed with exit code 1
  error: subprocess-exited-with-error
  
  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> See above for output.
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  full command: /home/spraul/miniconda3/envs/mmdeploy_cu118/bin/python -u -c '
  exec(compile('"'"''"'"''"'"'
  # This is <pip-setuptools-caller> -- a caller that pip uses to run setup.py
  #
  # - It imports setuptools before invoking setup.py, to enable projects that directly
  #   import from `distutils.core` to work with newer packaging standards.
  # - It provides a clear error message when setuptools is not installed.
  # - It sets `sys.argv[0]` to the underlying `setup.py`, when invoking `setup.py` so
  #   setuptools doesn'"'"'t think the script is `-c`. This avoids the following warning:
  #     manifest_maker: standard file '"'"'-c'"'"' not found".
  # - It generates a shim setup.py, for handling setup.cfg-only projects.
  import os, sys, tokenize
  
  try:
      import setuptools
  except ImportError as error:
      print(
          "ERROR: Can not execute `setup.py` since setuptools is not available in "
          "the build environment.",
          file=sys.stderr,
      )
      sys.exit(1)
  
  __file__ = %r
  sys.argv[0] = __file__
  
  if os.path.exists(__file__):
      filename = __file__
      with tokenize.open(__file__) as f:
          setup_py_code = f.read()
  else:
      filename = "<auto-generated setuptools caller>"
      setup_py_code = "from setuptools import setup; setup()"
  
  exec(compile(setup_py_code, filename, "exec"))
  '"'"''"'"''"'"' % ('"'"'/tmp/pip-install-364fs8ik/mmcv_ce57bb2421164066921883ae873dcad6/setup.py'"'"',), "<pip-setuptools-caller>", "exec"))' bdist_wheel -d /tmp/pip-wheel-drtpeg_y
  cwd: /tmp/pip-install-364fs8ik/mmcv_ce57bb2421164066921883ae873dcad6/
  Building wheel for mmcv (setup.py) ... error
  ERROR: Failed building wheel for mmcv
  Running setup.py clean for mmcv
  Running command python setup.py clean
  running clean
  removing 'build/temp.linux-x86_64-3.8' (and everything under it)
  removing 'build/lib.linux-x86_64-3.8' (and everything under it)
  'build/bdist.linux-x86_64' does not exist -- can't clean it
  'build/scripts-3.8' does not exist -- can't clean it
Failed to build mmcv
ERROR: Could not build wheels for mmcv, which is required to install pyproject.toml-based projects
@gnftau
Copy link

gnftau commented Feb 1, 2024

mim install -v -e . --> pip install -v -e . resolve this problem in my environment

@ngochungnguyenlg
Copy link

mim install -v -e . --> pip install -v -e . resolve this problem in my environment

This way does not work.
I have the same issue but i don't know how to fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants