[Bug] #error C++17 or later compatible compiler is required to use PyTorch
celpas opened this issue · 5 comments
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
Installation fail on MacOS 14 with PyTorch 2.1 due to #error C++17 or later compatible compiler is required to use PyTorch.
Similar to open-mmlab/mmcv#2916
Reproduction
pip install git+https://github.com/open-mmlab/mmdeploy.git@v1.3.0
Environment
Torch 2.1 installed with pip and Python 3.10.
Error traceback
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /Users/user/opt/anaconda3/envs/det_pt2/include -fPIC -O2 -isystem /Users/user/opt/anaconda3/envs/det_pt2/include -I/Users/user/opt/anaconda3/envs/det_pt2/lib/python3.10/site-packages/torch/include -I/Users/user/opt/anaconda3/envs/det_pt2/lib/python3.10/site-packages/torch/include/torch/csrc/api/include -I/Users/user/opt/anaconda3/envs/det_pt2/lib/python3.10/site-packages/torch/include/TH -I/Users/user/opt/anaconda3/envs/det_pt2/lib/python3.10/site-packages/torch/include/THC -I/Users/user/opt/anaconda3/envs/det_pt2/include/python3.10 -c ./csrc/mmdeploy/backend_ops/torchscript/optimizer/bind.cpp -o build/temp.macosx-10.9-x86_64-cpython-310/./csrc/mmdeploy/backend_ops/torchscript/optimizer/bind.o -std=c++14 -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE=\"_clang\" -DPYBIND11_STDLIB=\"_libcpp\" -DPYBIND11_BUILD_ABI=\"_cxxabi1002\" -DTORCH_EXTENSION_NAME=ts_optimizer -D_GLIBCXX_USE_CXX11_ABI=0
In file included from ./csrc/mmdeploy/backend_ops/torchscript/optimizer/bind.cpp:4:
In file included from /Users/user/opt/anaconda3/envs/det_pt2/lib/python3.10/site-packages/torch/include/torch/extension.h:5:
/Users/user/opt/anaconda3/envs/det_pt2/lib/python3.10/site-packages/torch/include/torch/csrc/api/include/torch/all.h:4:2: error: C++17 or later compatible compiler is required to use PyTorch.
#error C++17 or later compatible compiler is required to use PyTorch.
^
Hi, celpas.
U can change "csrc/mmdeploy/backend_ops/CMakeLists.txt" line 2, set(CMAKE_CXX_STANDARD 17).
I've been able to solve the issue setting the following extra compile argument inside setup.py
:
extra_compile_args['cxx'] = ['-std=c++17']
A PR should be opened on this as currently MMDeploy's compatibility with PyTorch 2.1 is broken. We can modify as follows:
extra_compile_args['cxx'] = ['-std=c++14']
if parse_version(torch.__version__) >= parse_version('2.0.0'):
extra_compile_args['cxx'] = ['-std=c++17']
hi, thanks for your feedback. Welcome PR to fix it.
This issue is marked as stale because it has been marked as invalid or awaiting response for 7 days without any further response. It will be closed in 5 days if the stale label is not removed or if there is no further response.
This issue is closed because it has been stale for 5 days. Please open a new issue if you have similar issues or you have any new updates now.