-
Notifications
You must be signed in to change notification settings - Fork 23k
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
[Caffe2] Windows build errors in generated file caffe2.pb.h #7962
Comments
My cmake output is: ******** Summary ******** BUILD_CAFFE2 : ON |
I modified build_windows.bat to use /MD instead of /MT, since my application needs to link with several other libraries that were compiled for /MD: if NOT DEFINED CMAKE_GENERATOR ( |
-DBUILD_SHARED_LIBS=ON seems to be the culprit. Builds fine if I leave it set to OFF. I don't particularly care if Caffe2 and friends build as static or shared libs. The problem is that pytorch\cmake\public\cuda.cmake defaults to /MT unless BUILD_SHARED_LIBS=ON. Building caffe2_gpu.lib with /MT prevents me from actually using it, since my application uses many other libs built with /MD (the Visual Studio default) and we don't have the option of recompiling them all from source. |
@peterjc123, I know this is touching the caffe2 bits as opposed to the pytorch bits, but do you have any insight here? |
The problem I was trying to solve was compiling caffe2 with /MD instead of /MT. Almost everywhere this is controlled by CAFFE2_USE_MSVC_STATIC_RUNTIME. I think there's a bad assumption in cuda.cmake, where this switch is instead controlled by BUILD_SHARED_LIBS (I don't agree that this should control /MT or /MD; static libs often need to be built with /MD). But I enabled BUILD_SHARED_LIBS anyway, which failed to build. I think, to be consistent, cuda.cmake should use CAFFE2_USE_MSVC_STATIC_RUNTIME e.g.:
As for the caffe2.pb.h compiler errors with BUILD_SHARED_LIBS, it beats me. |
@skelleher I don't quite get your idea. Is it that just simply change |
I remember I've seen this issue before. It's related to a funny combination of So...the solution is to patch protobuf... BTW this issue is on protobuf 3.5. |
@skelleher I think you might be right on using |
We are looking at the |
@skelleher this should be fixed as a part of #11266 . Closing. |
Note to anyone building caffe2 with CUDA 9.x on Windows; this build error was ultimately fixed by commit 9310eb1 / pull request #16251. Looks like that commit was not part of the v1.0.1 tag (last stable release). The commit adds a string replace to cmake/ProtoBufPatch.cmake to fix the build errors "*::kIndexInFileMessages may not be initialized" Also note: ProtoBufPatch.cmake only executes if CAFFE2_LINK_LOCAL_PROTOBUF is defined. |
Issue description
Windows build of caffe2 fails. Compiler errors in generated protobuf file caffe2.pb.h:
D:/code/pytorch/build\caffe2/proto/caffe2.pb.h(229): error : member "caffe2::TensorProto_Segment::kIndexInFileMessages" may not be initialized [D:\ code\pytorch\build\caffe2\caffe2_gpu.vcxproj]
The generated header looks OK:
Master branch git hash 9f21ec7 .
System Info
Caffe2
Did not install PyTorch, as I am building from source.
Opened Developer Command Prompt for VS 2017 (but see below)
Activated Python 2.7 environment
Ran cmake-gui - selected "Visual Studio 14 2015 Win64" generator
Configured Cmake options (mostly use defaults; see below)
Ran scripts\build_windows.bat
Windows 10
N/A
Anaconda 2.7.14 64-bit
CUDA 9.1 / cuDNN 7.1.3
GeForce GTX 980 Ti - 6 GB
N/A. VS 2017 (but using the included VS 2015 toolchain).
3.10.3
The text was updated successfully, but these errors were encountered: