Windows build failed
See original GitHub issue- OS: Microsoft Windows 7 Professional
- CMake version: version 3.17.1
- Python version: 3.7 (64-bit runtime)
- Is CUDA available: N/A
- [pip3] numpy==1.18.5
- [pip3] torch==1.7.1+cpu
- [pip3] torchaudio==0.7.2
- [pip3] torchvision==0.8.2+cpu
I am trying to build torch vision 0.8.2 from source using CMake but build fails.
I used the command:
cmake -DCMAKE_PREFIX_PATH="E:/Dev/ext/libs/libtorch-win-shared-with-deps-debug-1.7.1+cpu/libtorch; -DCMAKE_INSTALL_PREFIX="E:/Dev/ext/libs/pytorch_vision/install" -DCMAKE_BUILD_TYPE=Release --DWITH_CUDA=OFF ...
but then running
cmake --build .
the output is:
1>deform_conv2d.cpp 1>E:\Dev\ext\libs\pytorch_vision\torchvision\csrc\ops\deform_conv2d.cpp(86,24): error C2065: ‘torchvision’: undeclared identifier 1>E:\Dev\ext\libs\pytorch_vision\torchvision\csrc\ops\deform_conv2d.cpp(86,37): error C2065: ‘m’: undeclared identifier 1>E:\Dev\ext\libs\pytorch_vision\torchvision\csrc\ops\deform_conv2d.cpp(86,38): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>E:\Dev\ext\libs\pytorch_vision\torchvision\csrc\ops\deform_conv2d.cpp(86,40): error C2448: ‘vision::ops::TORCH_LIBRARY_FRAGMENT’: function-style initializer appears to be a function definition 1>nms.cpp 1>E:\Dev\ext\libs\pytorch_vision\torchvision\csrc\ops\nms.cpp(18,24): error C2065: ‘torchvision’: undeclared identifier 1>E:\Dev\ext\libs\pytorch_vision\torchvision\csrc\ops\nms.cpp(18,37): error C2065: ‘m’: undeclared identifier 1>E:\Dev\ext\libs\pytorch_vision\torchvision\csrc\ops\nms.cpp(18,38): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>E:\Dev\ext\libs\pytorch_vision\torchvision\csrc\ops\nms.cpp(18,40): error C2448: ‘vision::ops::TORCH_LIBRARY_FRAGMENT’: function-style initializer appears to be a function definition 1>ps_roi_align.cpp 1>E:\Dev\ext\libs\pytorch_vision\torchvision\csrc\ops\ps_roi_align.cpp(56,24): error C2065: ‘torchvision’: undeclared identifier 1>E:\Dev\ext\libs\pytorch_vision\torchvision\csrc\ops\ps_roi_align.cpp(56,37): error C2065: ‘m’: undeclared identifier 1>E:\Dev\ext\libs\pytorch_vision\torchvision\csrc\ops\ps_roi_align.cpp(56,38): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>E:\Dev\ext\libs\pytorch_vision\torchvision\csrc\ops\ps_roi_align.cpp(56,40): error C2448: ‘vision::ops::TORCH_LIBRARY_FRAGMENT’: function-style initializer appears to be a function definition 1>ps_roi_pool.cpp 1>E:\Dev\ext\libs\pytorch_vision\torchvision\csrc\ops\ps_roi_pool.cpp(52,24): error C2065: ‘torchvision’: undeclared identifier 1>E:\Dev\ext\libs\pytorch_vision\torchvision\csrc\ops\ps_roi_pool.cpp(52,37): error C2065: ‘m’: undeclared identifier 1>E:\Dev\ext\libs\pytorch_vision\torchvision\csrc\ops\ps_roi_pool.cpp(52,38): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>E:\Dev\ext\libs\pytorch_vision\torchvision\csrc\ops\ps_roi_pool.cpp(52,40): error C2448: ‘vision::ops::TORCH_LIBRARY_FRAGMENT’: function-style initializer appears to be a function definition 1>roi_align.cpp 1>E:\Dev\ext\libs\pytorch_vision\torchvision\csrc\ops\roi_align.cpp(66,24): error C2065: ‘torchvision’: undeclared identifier 1>E:\Dev\ext\libs\pytorch_vision\torchvision\csrc\ops\roi_align.cpp(66,37): error C2065: ‘m’: undeclared identifier 1>E:\Dev\ext\libs\pytorch_vision\torchvision\csrc\ops\roi_align.cpp(66,38): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>E:\Dev\ext\libs\pytorch_vision\torchvision\csrc\ops\roi_align.cpp(66,40): error C2448: ‘vision::ops::TORCH_LIBRARY_FRAGMENT’: function-style initializer appears to be a function definition 1>roi_pool.cpp 1>E:\Dev\ext\libs\pytorch_vision\torchvision\csrc\ops\roi_pool.cpp(51,24): error C2065: ‘torchvision’: undeclared identifier 1>E:\Dev\ext\libs\pytorch_vision\torchvision\csrc\ops\roi_pool.cpp(51,37): error C2065: ‘m’: undeclared identifier 1>E:\Dev\ext\libs\pytorch_vision\torchvision\csrc\ops\roi_pool.cpp(51,38): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>E:\Dev\ext\libs\pytorch_vision\torchvision\csrc\ops\roi_pool.cpp(51,40): error C2448: ‘vision::ops::TORCH_LIBRARY_FRAGMENT’: function-style initializer appears to be a function definition 1>vision.cpp 1>E:\Dev\ext\libs\pytorch_vision\torchvision\csrc\vision.cpp(31,24): error C2065: ‘torchvision’: undeclared identifier 1>E:\Dev\ext\libs\pytorch_vision\torchvision\csrc\vision.cpp(31,37): error C2065: ‘m’: undeclared identifier 1>E:\Dev\ext\libs\pytorch_vision\torchvision\csrc\vision.cpp(31,38): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>E:\Dev\ext\libs\pytorch_vision\torchvision\csrc\vision.cpp(31,40): error C2448: ‘vision::TORCH_LIBRARY_FRAGMENT’: function-style initializer appears to be a function definition 1>Generating Code… 1>Done building project “torchvision.vcxproj” – FAILED. 2>------ Build started: Project: ALL_BUILD, Configuration: Debug x64 ------ 2>Building Custom Rule E:/Dev/ext/libs/pytorch_vision/CMakeLists.txt
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
@datumbox No, I am using libtorch1.7.1+cpu torchvision0.8.2
Installing libtorch nightly did not solve the problem either.
I had to modify the macro
TORCH_LIBRARY_FRAGMENT
withTORCH_LIBRARY_FRAGMENT_THIS_API_IS_FOR_PER_OP_REGISTRATION_ONLY
in torchvision src files.Not sure this is a good solution but the build finishes with no errors.
@dc986 Building TorchVision from source should be done by running:
python setup.py install
For details on how to compile from source check our contributing page. Just replace nightly with the latest stable version of PyTorch since you want to build v0.8.2.
Using cmake is something we plan to support on the future. See #2349
@zsef123 You should do the same as described above. The only difference is that you need to install the nightly PyTorch lib because the current master of TorchVision depends on it.