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

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

Closed
damonftl opened this issue Oct 16, 2020 · 11 comments · Fixed by #766
Closed

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

damonftl opened this issue Oct 16, 2020 · 11 comments · Fixed by #766
Labels
enhancement New feature or request windows About windows incompatibility

Comments

@damonftl
Copy link

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 ZwwWayne added the enhancement New feature or request label Oct 17, 2020
@ZwwWayne
Copy link
Collaborator

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

@ZwwWayne ZwwWayne added the windows About windows incompatibility label Oct 17, 2020
@damonftl
Copy link
Author

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
Copy link
Collaborator

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

@huixiancheng
Copy link

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

@damonftl
Copy link
Author

@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
Copy link

divyanshj16 commented May 12, 2021

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

@divyanshj16
Copy link

@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
Copy link
Author

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
Copy link

divyanshj16 commented May 17, 2021

@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
Copy link

I was able to fix these issues: #551

tpoisonooo pushed a commit to tpoisonooo/mmdetection3d that referenced this issue Sep 5, 2022
…en-mmlab#169)

* add ppl install doc and how to test a model doc

* remove mmdet model list in ppl.md

* resolve comments

* fix typo

* add mmocr doc

* mv configs as the final column

* fix typo and align tables

* fix lint
tpoisonooo pushed a commit to tpoisonooo/mmdetection3d that referenced this issue Sep 5, 2022
* support export hardsigmoid in torch<=1.8

* fix lint
@ShaneCan
Copy link

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request windows About windows incompatibility
Projects
None yet
5 participants