This PR updates Windows build via CMake and build instructions. With https://github.com/marian-nmt/marian-dev/pull/676, this should be fully workable, including CUDA, FBGEMM, SentencePiece, unit tests, marian-server. List of changes: - Fixing compilation of marian-server on Windows via CMake - Updating vs/CheckDeps.bat - zlib no longer needs to be installed as it is included in 3rd_party - Installing Boost 1.72 since newer is not supported - Installing minimal required Boost components in CheckDeps.bat - Installing protobuf in CheckDeps.bat - Updating CMakeSettings.json - Updating vs/README.md - Development notes extracted to vs/NOTES.md I did not update and test with CUDA, because I do not have a machine for that, but AFAIK it works properly.
4.1 KiB
How to build Marian on Windows with GPU support
This is interesting for developers, exctracted from README.
Changes from the master branch
This part gives more information on all changes done in this PR. Refer to this page for commits.
-
Fix Cuda error : Unsupported Visual Studio Version Error See above for justification and fixes
-
Fix VS compiler flags / Build in Release, with improved debug info Added VS specific compile and link flags
-
Fix Warning: D9002: ignoring unknown option '-m64' This one is related to a compiler flag added while finding the package MKL that does not exists for MS compiler.
-
Fix marian::Backend, marian::cpu::Backend and marian::gpu::Backend conflicts There were name conflicts between the 3
Backend
classes that confused the compiler:template instantiation resulted in unexpected function type of "void(Ptr<marian::gpu::Backend> backend, [...])" (the meaning of a name may have changed since the template declaration -- the type of the template is "void(Ptr<marian::Backend> backend, [...]").
To solve this, I changed the declaration of 3 methods to specify the full name with namespace (
marian::Backend
, instead ofBackend
). -
Fix error : identifier "CUDA_FLT_MAX" is undefined in device code
CUDA_FLT_MAX
is not seen by CUDA from the device code and I had to declare it as__constant__
.From StackOverflow:
Undecorated constants get compiled into both host and device code with gcc based toolchains, but not with the Microsoft compiler.
-
Fix fatal error C1019: unexpected #else There was preprocessor instructions (
#ifdef ... #else ... #endif
) in the middle of a call of a macro function (CUDNN_CALL
), which is not allowed with MS compiler. -
Fix mismatched class/struct forward declarations Microsoft's C++ name mangling makes a distinction between
class
andstruct
objects, so definitions and forward declaration must match. See this pdf, page 27, for more information.Note: This fix was invalidated by commit # from @frankseide
-
Fix unresolved external due to a removed #include directive There was an include directive removed from MSVC compilation, but this prevented the build of the project. I'm not sure why this was removed; the comment is:
#ifndef _WIN32 // TODO: remove this once I updated the Linux-side makefile
-
Fix CUDA+MSVC incompatibility with Boost.Preprocessor The toolchain nvcc+msvc is not correctly handled in Boost.Preprocessor module. See this issue. In the meantime, the recommended workaround is to disable Variadic Macro support in Boost. I created a PR in the Boost repo on GitHub to fix this.
Note: The library sources have been fixed, but this fix is still needed until the next release of Boost.Preprocessor
-
Provide implementation for mkstemp / Fix temporary file creation The code explicitely disabled the creation of temporary files because "mkstemp not available in Windows". In fact,
mktemp
andunlink
are both implemented, but they don't work as expected. I usedtempnam
to replacemkstemp
, and added the flag_O_TEMPORARY
to the parameters ofopen
to automatically delete the file when it is closed. IfunlinkEarly
is not set, I added a call toremove
in the destructor to delete the file after its closure. I also handled the case of the default value for thebase
parameter: the path\tmp
doesnot exist on Windows, so it is replaced by the value of the%TMP%
environment variable inNormalizeTempPrefix
. -
Revert commit #2f8b093 + Fix copy/paste error while fixing #301 + restrict fix to MSVC compiler. cf Issue #301 -->