open-mmlab / mmdetection3d

OpenMMLab's next-generation platform for general 3D object detection.
https://mmdetection3d.readthedocs.io/en/latest/
Apache License 2.0
5.18k stars 1.52k forks source link

compilation error C2131: expression did not evaluate to a constant #169

Closed damonftl closed 3 years ago

damonftl commented 3 years ago

Hi, I'm trying to install and use mmdetection on my Windows 10 machine (I know, that's my first problem...) and I'm at literally the last step of the process. Everything appears to have installed and compiled correctly up to this point, but when running the "pip install -v -e ." inside the mmdetection3d directory I receive the following errors for iou3d:

D:\Code\3DDetection\mmdetection3d\mmdet3d\ops\iou3d\src\iou3d.cpp(108): error C2131: expression did not evaluate to a constant
D:\Code\3DDetection\mmdetection3d\mmdet3d\ops\iou3d\src\iou3d.cpp(108): note: failure was caused by a read of a variable outside its lifetime
D:\Code\3DDetection\mmdetection3d\mmdet3d\ops\iou3d\src\iou3d.cpp(108): note: see usage of 'boxes_num'
D:\Code\3DDetection\mmdetection3d\mmdet3d\ops\iou3d\src\iou3d.cpp(127): error C2131: expression did not evaluate to a constant
D:\Code\3DDetection\mmdetection3d\mmdet3d\ops\iou3d\src\iou3d.cpp(108): note: failure was caused by a read of a variable outside its lifetime
D:\Code\3DDetection\mmdetection3d\mmdet3d\ops\iou3d\src\iou3d.cpp(108): note: see usage of 'boxes_num'
D:\Code\3DDetection\mmdetection3d\mmdet3d\ops\iou3d\src\iou3d.cpp(181): error C2131: expression did not evaluate to a constant
D:\Code\3DDetection\mmdetection3d\mmdet3d\ops\iou3d\src\iou3d.cpp(162): note: failure was caused by a read of a variable outside its lifetime
D:\Code\3DDetection\mmdetection3d\mmdet3d\ops\iou3d\src\iou3d.cpp(162): note: see usage of 'boxes_num'

In researching this particular error, it appears to be a problem with the compiler in Windows. The problem is line 108 mentioned in the above errors:

const int col_blocks = DIVUP(boxes_num, THREADS_PER_BLOCK_NMS);

and then its use on line 127 to initialize an array:

unsigned long long remv_cpu[col_blocks];

Apparently some compilers are okay with this and some, specifically in Windows apparently, are not. I do not know how to work around this problem. I have tried various things mentioned in places like StackOverflow, like setting col_blocks to be static, but the same error appears. I have also checked the issue queue for OpenPCDet, where the original code for iou3d came from, but nobody seems to have this problem. Does anyone know of a way around this?

ZwwWayne commented 3 years ago

This is about the windows compatibility issue. We may not be able to fix it quickly because currently, we do not have windows machines.

damonftl commented 3 years ago

Thank you for the reply. I'll keep on it myself for a while and see if I can come up with a workaround. If I do I'll be sure to post the solution here.

ZwwWayne commented 3 years ago

Great! Feel free to create a PR to solve it if you find any solution. Thanks in advance.

huixiancheng commented 3 years ago

sir,I have the same problem too.Have you find the way to slove it? @damonftl

damonftl commented 3 years ago

@huixiancheng I did not end up solving it, sorry about that. I actually went as far as installing Linux and dual-booting just so I could try this out (and it did work fine in Linux). I did manage to get VoteNet (https://github.com/facebookresearch/votenet) working in Windows with some small code adjustments. You may be able to get that one going.

divyanshj16 commented 3 years ago

@ZwwWayne Did you find a way around it? Because I am still running into this issue.

divyanshj16 commented 3 years ago

@huixiancheng I did not end up solving it, sorry about that. I actually went as far as installing Linux and dual-booting just so I could try this out (and it did work fine in Linux). I did manage to get VoteNet (https://github.com/facebookresearch/votenet) working in Windows with some small code adjustments. You may be able to get that one going.

Can you tell me the code adjustments you made?

damonftl commented 3 years ago

Of course it was five months ago now and I don't completely remember everything I had to do, sorry about that. I know it was not very much. Dependency versions have to be exactly correct or it won't work and you'll get weird and often misleading errors. For some reason batch sizes in Windows have to be set lower than in Linux or you'll get GPU memory errors (maybe something with nvidia's drivers? I don't know). I just searched through the code real quick and didn't see any big obvious edits. A quick google search should likely provide solutions to the problems you might hit.

The really hard part was getting it to work with our custom data, but that would be true in Linux as well.

divyanshj16 commented 3 years ago

@ZwwWayne @damonftl

Hi, the line which was causing error it got resolved by changing the the erroring line to dynamic array allocation at two places unsigned long long *remv_cpu = new unsigned long long [col_blocks]; Now, the original error is gone, but I have a couple of errors, please help me fix it. Initially it says this.

    writing mmdet3d.egg-info\PKG-INFO
    writing dependency_links to mmdet3d.egg-info\dependency_links.txt
    writing requirements to mmdet3d.egg-info\requires.txt
    writing top-level names to mmdet3d.egg-info\top_level.txt
    reading manifest file 'mmdet3d.egg-info\SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    warning: no files found matching 'mmdet3d\requirements\*.txt'
    warning: no files found matching 'mmdet3d\ops\**\*.cpp'
    warning: no files found matching 'mmdet3d\ops\**\*.cu'
    warning: no files found matching 'mmdet3d\ops\**\*.h'
    warning: no files found matching 'mmdet3d\ops\**\*.cc'
    warning: no files found matching 'mmdet3d\VERSION'
    warning: no files found matching 'mmdet3d\model_zoo.yml'
    warning: no files found matching 'mmdet3d\configs\*\*.py'
    warning: no files found matching 'mmdet3d\configs\*\*.yml'
    warning: no files found matching 'mmdet3d\tools\*.py'
    warning: no files found matching 'mmdet3d\tools\*.sh'
    warning: no files found matching 'mmdet3d\tools\*\*.py'
    warning: no files found matching 'mmdet3d\demo\*\*'

The mmdet3d.ops.spconv.sparse_conv_ext did not throw any error. But

while compiling mmdet3d.ops.iou3d.iou3d_cuda

    building 'mmdet3d.ops.iou3d.iou3d_cuda' extension
    Emitting ninja build file C:\Users\div10433\OneDrive - Esri\office-work\058-mmdet-3d\mmdetection3d\build\temp.win-amd64-3.7\Release\build.ninja...
    Compiling objects...
    Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N)
    ninja: no work to do.
    C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.28.29333\bin\HostX86\x64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:C:\Users\div10433\.conda\envs\mmcv\lib\site-packages\torch\lib "/LIBPATH:C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\lib/x64" /LIBPATH:C:\Users\div10433\.conda\envs\mmcv\libs /LIBPATH:C:\Users\div10433\.conda\envs\mmcv\PCbuild\amd64 "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.28.29333\ATLMFC\lib\x64" "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.28.29333\lib\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64" c10.lib torch.lib torch_cpu.lib torch_python.lib cudart.lib c10_cuda.lib torch_cuda.lib /EXPORT:PyInit_iou3d_cuda "C:\Users\div10433\OneDrive - Esri\office-work\058-mmdet-3d\mmdetection3d\build\temp.win-amd64-3.7\Release\mmdet3d\ops\iou3d\src/iou3d.obj" "C:\Users\div10433\OneDrive - Esri\office-work\058-mmdet-3d\mmdetection3d\build\temp.win-amd64-3.7\Release\mmdet3d\ops\iou3d\src/iou3d_kernel.obj" /OUT:build\lib.win-amd64-3.7\mmdet3d\ops\iou3d\iou3d_cuda.cp37-win_amd64.pyd "/IMPLIB:C:\Users\div10433\OneDrive - Esri\office-work\058-mmdet-3d\mmdetection3d\build\temp.win-amd64-3.7\Release\mmdet3d\ops\iou3d\src\iou3d_cuda.cp37-win_amd64.lib"
       Creating library C:\Users\div10433\OneDrive - Esri\office-work\058-mmdet-3d\mmdetection3d\build\temp.win-amd64-3.7\Release\mmdet3d\ops\iou3d\src\iou3d_cuda.cp37-win_amd64.lib and object C:\Users\div10433\OneDrive - Esri\office-work\058-mmdet-3d\mmdetection3d\build\temp.win-amd64-3.7\Release\mmdet3d\ops\iou3d\src\iou3d_cuda.cp37-win_amd64.exp
    iou3d.obj : error LNK2001: unresolved external symbol "public: long * __cdecl at::Tensor::data_ptr<long>(void)const " (??$data_ptr@J@Tensor@at@@QEBAPEAJXZ)
    build\lib.win-amd64-3.7\mmdet3d\ops\iou3d\iou3d_cuda.cp37-win_amd64.pyd : fatal error LNK1120: 1 unresolved externals
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Professional\\VC\\Tools\\MSVC\\14.28.29333\\bin\\HostX86\\x64\\link.exe' failed with exit status 1120
    Error in atexit._run_exitfuncs:
    Traceback (most recent call last):
      File "C:\Users\div10433\.conda\envs\mmcv\lib\site-packages\colorama\ansitowin32.py", line 59, in closed
        return stream.closed
    ValueError: underlying buffer has been detached
ERROR: Command errored out with exit status 1: 'C:\Users\div10433\.conda\envs\mmcv\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\div10433\\OneDrive - Esri\\office-work\\058-mmdet-3d\\mmdetection3d\\setup.py'"'"'; __file__='"'"'C:\\Users\\div10433\\OneDrive - Esri\\office-work\\058-mmdet-3d\\mmdetection3d\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps Check the logs for full command output.
divyanshj16 commented 3 years ago

I was able to fix these issues: https://github.com/open-mmlab/mmdetection3d/pull/551

ShaneCan commented 1 year ago

@ZwwWayne @damonftl

Hi, the line which was causing error it got resolved by changing the the erroring line to dynamic array allocation at two places unsigned long long *remv_cpu = new unsigned long long [col_blocks]; Now, the original error is gone, but I have a couple of errors, please help me fix it. Initially it says this.

    writing mmdet3d.egg-info\PKG-INFO
    writing dependency_links to mmdet3d.egg-info\dependency_links.txt
    writing requirements to mmdet3d.egg-info\requires.txt
    writing top-level names to mmdet3d.egg-info\top_level.txt
    reading manifest file 'mmdet3d.egg-info\SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    warning: no files found matching 'mmdet3d\requirements\*.txt'
    warning: no files found matching 'mmdet3d\ops\**\*.cpp'
    warning: no files found matching 'mmdet3d\ops\**\*.cu'
    warning: no files found matching 'mmdet3d\ops\**\*.h'
    warning: no files found matching 'mmdet3d\ops\**\*.cc'
    warning: no files found matching 'mmdet3d\VERSION'
    warning: no files found matching 'mmdet3d\model_zoo.yml'
    warning: no files found matching 'mmdet3d\configs\*\*.py'
    warning: no files found matching 'mmdet3d\configs\*\*.yml'
    warning: no files found matching 'mmdet3d\tools\*.py'
    warning: no files found matching 'mmdet3d\tools\*.sh'
    warning: no files found matching 'mmdet3d\tools\*\*.py'
    warning: no files found matching 'mmdet3d\demo\*\*'

The mmdet3d.ops.spconv.sparse_conv_ext did not throw any error. But

while compiling mmdet3d.ops.iou3d.iou3d_cuda

    building 'mmdet3d.ops.iou3d.iou3d_cuda' extension
    Emitting ninja build file C:\Users\div10433\OneDrive - Esri\office-work\058-mmdet-3d\mmdetection3d\build\temp.win-amd64-3.7\Release\build.ninja...
    Compiling objects...
    Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N)
    ninja: no work to do.
    C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.28.29333\bin\HostX86\x64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:C:\Users\div10433\.conda\envs\mmcv\lib\site-packages\torch\lib "/LIBPATH:C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\lib/x64" /LIBPATH:C:\Users\div10433\.conda\envs\mmcv\libs /LIBPATH:C:\Users\div10433\.conda\envs\mmcv\PCbuild\amd64 "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.28.29333\ATLMFC\lib\x64" "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.28.29333\lib\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64" c10.lib torch.lib torch_cpu.lib torch_python.lib cudart.lib c10_cuda.lib torch_cuda.lib /EXPORT:PyInit_iou3d_cuda "C:\Users\div10433\OneDrive - Esri\office-work\058-mmdet-3d\mmdetection3d\build\temp.win-amd64-3.7\Release\mmdet3d\ops\iou3d\src/iou3d.obj" "C:\Users\div10433\OneDrive - Esri\office-work\058-mmdet-3d\mmdetection3d\build\temp.win-amd64-3.7\Release\mmdet3d\ops\iou3d\src/iou3d_kernel.obj" /OUT:build\lib.win-amd64-3.7\mmdet3d\ops\iou3d\iou3d_cuda.cp37-win_amd64.pyd "/IMPLIB:C:\Users\div10433\OneDrive - Esri\office-work\058-mmdet-3d\mmdetection3d\build\temp.win-amd64-3.7\Release\mmdet3d\ops\iou3d\src\iou3d_cuda.cp37-win_amd64.lib"
       Creating library C:\Users\div10433\OneDrive - Esri\office-work\058-mmdet-3d\mmdetection3d\build\temp.win-amd64-3.7\Release\mmdet3d\ops\iou3d\src\iou3d_cuda.cp37-win_amd64.lib and object C:\Users\div10433\OneDrive - Esri\office-work\058-mmdet-3d\mmdetection3d\build\temp.win-amd64-3.7\Release\mmdet3d\ops\iou3d\src\iou3d_cuda.cp37-win_amd64.exp
    iou3d.obj : error LNK2001: unresolved external symbol "public: long * __cdecl at::Tensor::data_ptr<long>(void)const " (??$data_ptr@J@Tensor@at@@QEBAPEAJXZ)
    build\lib.win-amd64-3.7\mmdet3d\ops\iou3d\iou3d_cuda.cp37-win_amd64.pyd : fatal error LNK1120: 1 unresolved externals
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Professional\\VC\\Tools\\MSVC\\14.28.29333\\bin\\HostX86\\x64\\link.exe' failed with exit status 1120
    Error in atexit._run_exitfuncs:
    Traceback (most recent call last):
      File "C:\Users\div10433\.conda\envs\mmcv\lib\site-packages\colorama\ansitowin32.py", line 59, in closed
        return stream.closed
    ValueError: underlying buffer has been detached
ERROR: Command errored out with exit status 1: 'C:\Users\div10433\.conda\envs\mmcv\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\div10433\\OneDrive - Esri\\office-work\\058-mmdet-3d\\mmdetection3d\\setup.py'"'"'; __file__='"'"'C:\\Users\\div10433\\OneDrive - Esri\\office-work\\058-mmdet-3d\\mmdetection3d\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps Check the logs for full command output.

have you solved this problem? i met the same problem... if you could help im really appreciate that , thx