From de760818fd33bc5777b48ee0f07c5fa9dd997e3c Mon Sep 17 00:00:00 2001 From: Jens Date: Wed, 17 Apr 2019 21:41:53 +0200 Subject: [PATCH] Tensorflow can be built from standard repo + VS 2017 patches applied by script before build -> removes necessity of extra tf fork + builds take place in cache folder + resolved duplicated include folders in lib/ --- .gitignore | 1 - README.md | 27 +- Tensorflow.props | 2 +- build/.gitignore | 262 ++++++++++++++++++ build/build_tensorflow_with_cmake.bat | 99 +++++-- .../cmake environment for x64 build tools.cmd | 3 - ...3.6.1-to-fix-vs-2017-debug-assertion.patch | 25 ++ ...guration-cmake-grpc-was-always-built.patch | 41 +++ ...al-Studio-Debug-build-compile-errors.patch | 49 ++++ ...al-Studio-Debug-build-LNK2019-errors.patch | 74 +++++ 10 files changed, 538 insertions(+), 45 deletions(-) create mode 100644 build/.gitignore delete mode 100644 build/cmake environment for x64 build tools.cmd create mode 100644 build/patches/tensorflow/r1.10/0001-Using-protobuf-3.6.1-to-fix-vs-2017-debug-assertion.patch create mode 100644 build/patches/tensorflow/r1.10/0002-Fixed-grpc-Configuration-cmake-grpc-was-always-built.patch create mode 100644 build/patches/tensorflow/r1.13/0001-Fix-Visual-Studio-Debug-build-compile-errors.patch create mode 100644 build/patches/tensorflow/r1.13/0002-Fix-Visual-Studio-Debug-build-LNK2019-errors.patch diff --git a/.gitignore b/.gitignore index fa9dbf8..86b84a1 100644 --- a/.gitignore +++ b/.gitignore @@ -267,4 +267,3 @@ __pycache__/ # ignore generated files from build /tensorflow* -/*/ \ No newline at end of file diff --git a/README.md b/README.md index ce6007e..60fe7a6 100644 --- a/README.md +++ b/README.md @@ -20,26 +20,33 @@ Adding the build customisation file to a project automatically enables access to Download OpenCV 4.0.1 into the lib directory and rename the folder to "OpenCV 4.0.1". -### Building Tensorflow 1.10 with cmake and Visual Studio 2017 +### Building Tensorflow 1.10 with CMake and Visual Studio 2017 1. Install Visual Studio 2017 Community Edition, Python 3.66, Git, Cuda 10 -2. Enable long filename for Git, otherwise you'll might not get very far. +2. Enable long filenames for Git, otherwise you'll might not get very far: +``` +git config --system core.longpaths true +``` -3. Enable long file names in Windows 10. +3. Enable long filenames in Windows 10 for the same reason : + - https://www.howtogeek.com/266621/how-to-make-windows-10-accept-file-paths-over-260-characters/ + - https://docs.microsoft.com/en-us/windows/desktop/fileio/naming-a-file Currently, only TensorFlow r1.10 is supported, for a couple of reasons: 1. It is the last version that that officially supports CUDA Compute Caps 3.5, and therefore runs with my slightly outdated 2013 GPU (NVidia Titan). 2. The cmake build supports Cuda 10. 3. The bazel Windows build (as of tf r1.10) has lots of issues. -4. Only 2 patches were necessary to build with Visual Studio 2017. +4. Builds with Visual Studio 2017 after applying two patches. +5. Debug build is fully supported - won't work with Bazel build either. -Open a Visual Studio 2017 x64 command prompt and execute the build script +Open a Visual Studio 2017 x64 command prompt and execute the build script that matches your hardware configuration ``` -`build_tensorflow_r1.10-cmake-all.bat`. +build_tensorflow_r1.10-cmake-cpu.bat +build_tensorflow_r1.10-cmake-cuda.bat ``` -The script downloads the patched fork of the TensorFlow r.1.10 branch, creates Visual Studio Solutions via CMake, and then invokes MSBuild to build targets for several CPU/GPU configurations. The build should take about half a day or so and leaves you with a couple of TensorFlow dlls in `lib\tensorflow\r1.10\vc15` for Debug, avx, avx2, cuda, cuda-avx & avx2-fma configurations. +The script clones TensorFlow r.1.10 branch, applies patches to enable building with Visual Studio 2017, creates Visual Studio solutions via CMake, and then invokes MSBuild to build targets for several CPU/GPU configurations. The build should take about half a day or so and leaves you with a couple of TensorFlow dlls in `lib\tensorflow\r1.10\vc15` for Debug, avx, avx2, cuda, cuda-avx & avx2-fma configurations. You can build a single configuration with `build_tensorflow_with_cmake.bat "VS Configuration"`, for instance ``` @@ -50,15 +57,13 @@ The special fma build will be included into the avx2 build later on, but I'm int There's no /GL build yet because it exceeds the 4G size limit of the COFF file format. -Include files are duplicated in each configuration on install, that's because each cpu/gpu variant is built as a single CMake solution. - -The cpu/gpu arch is simply matched via the configuration name, so the project references Debug/Release (both built with AVX) automatically. To match additional build-config library, just name them after the folder that contains the specific version of Tensorflow. (For instance `Release-cuda-avx2`) +The cpu/gpu arch is simply matched via the configuration name, so the project references Debug/Release (both built with AVX) automatically. To match a build configuration, just name it after the folder that contains the specific version of Tensorflow. (For instance `Release-cuda-avx2`) ### Running the test project "Hello Tensorflow" A hello-world example derived from https://joe-antognini.github.io/machine-learning/windows-tf-project, plus a Google test suite to assert that the library works. -If you build and run the Hello-Word example, the console should display the expected result +When you build and run the Hello-Word example, the console should display the expected result ``` 7 17 -1 -3 diff --git a/Tensorflow.props b/Tensorflow.props index aaa2e2f..814d264 100644 --- a/Tensorflow.props +++ b/Tensorflow.props @@ -6,7 +6,7 @@ <_PropertySheetDisplayName>TensorFlow $(MSBuildThisFileDirectory)tensorflow\r1.10\ $(TENSORFLOW_DIR)$(VS_VERSION)\$(Configuration)\bin\;$(ExecutablePath) - $(TENSORFLOW_DIR)$(VS_VERSION)\$(Configuration)\include\;$(IncludePath) + $(TENSORFLOW_DIR)include\;$(IncludePath) $(TENSORFLOW_DIR)$(VS_VERSION)\$(Configuration)\lib\;$(LibraryPath) diff --git a/build/.gitignore b/build/.gitignore new file mode 100644 index 0000000..67d24e5 --- /dev/null +++ b/build/.gitignore @@ -0,0 +1,262 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# DNX +project.lock.json +project.fragment.lock.json +artifacts/ + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +#*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config +# NuGet v3's project.json files produces more ignoreable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +node_modules/ +orleans.codegen.cs + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc +/cache diff --git a/build/build_tensorflow_with_cmake.bat b/build/build_tensorflow_with_cmake.bat index 2fb2c54..d6812e5 100644 --- a/build/build_tensorflow_with_cmake.bat +++ b/build/build_tensorflow_with_cmake.bat @@ -2,8 +2,19 @@ REM %1 = configuration REM %2 = path to tensorflow sources REM %3 = build dir +set PreferredToolArchitecture=x64 + +set CMAKE_SCRIPTS=%~dp0\scripts +call %CMAKE_SCRIPTS%\cmake_build_path.bat +call %CMAKE_SCRIPTS%\cmake_cuda_path.bat +call %CMAKE_SCRIPTS%\cmake_build_config.bat + + REM Defaults +set ROOT=%~dp0 +set BUILD_CACHE=%ROOT%cache\ + if NOT [%1] == [] ( set VS_SOLUTION_DIR_NAME=%1 )else ( @@ -13,47 +24,44 @@ if NOT [%1] == [] ( if NOT [%2] == [] ( set TENSORFLOW_SOURCES=%2 )else ( - set TENSORFLOW_SOURCES=%~dp0\tensorflow_r1.10-cmake + set TENSORFLOW_SOURCES=%BUILD_CACHE%tensorflow_%TENSORFLOW_RELEASE%-cmake ) -REM if NOT [%3] == [] ( -REM set TENSORFLOW_BUILD_DIR=%3 -REM )else ( -REM set TENSORFLOW_BUILD_DIR=%~dp0\cmake -REM ) - if EXIST "%TENSORFLOW_SOURCES%\.git" ( pushd "%TENSORFLOW_SOURCES%" git pull popd -)else ( - git clone --single-branch --branch r1.10 https://github.com/jenshemprich/tensorflow.git "%TENSORFLOW_SOURCES%" +) else ( + git clone --single-branch --branch %TENSORFLOW_RELEASE% https://github.com/tensorflow/tensorflow.git "%TENSORFLOW_SOURCES%" + pushd "%TENSORFLOW_SOURCES%" + REM TODO enum files at runtime + git am --signoff %ROOT%patches\tensorflow\r1.10\0001-Using-protobuf-3.6.1-to-fix-vs-2017-debug-assertion.patch + git am --signoff %ROOT%patches\tensorflow\r1.10\0002-Fixed-grpc-Configuration-cmake-grpc-was-always-built.patch + popd ) REM cmake parameters -set CMAKE_SCRIPTS=%~dp0\scripts -call %CMAKE_SCRIPTS%\cmake_build_path.bat -call %CMAKE_SCRIPTS%\cmake_cuda_path.bat -call %CMAKE_SCRIPTS%\cmake_build_config.bat - set CMAKE_CXX_FLAGS= set CMAKE_LINKER_FLAGS= +set TENSORFLOW_ENABLE_MKL_FLAG="OFF" REM /O2 is automatically set by cmake if /I %VS_SOLUTION_DIR_NAME%==Debug ( - set TENSORFLOW_WIN_CPU_SIMD_OPTION="/arch:AVX" set CMAKE_CONFIGURATION_TYPE=Debug + set TENSORFLOW_WIN_CPU_SIMD_OPTION="/arch:AVX" ) else ( + set CMAKE_CONFIGURATION_TYPE=Release + if /I not x%VS_SOLUTION_DIR_NAME:avx2=%==x%VS_SOLUTION_DIR_NAME% ( set TENSORFLOW_WIN_CPU_SIMD_OPTION="/arch:AVX2" REM global optimization build for benchmarking (does not work yet) if /I not x%VS_SOLUTION_DIR_NAME:avx2-fma-gl=%==x%VS_SOLUTION_DIR_NAME% ( - echo "Warning: using option /GL exceeds COFF file size of 4G" - echo "Warning: cmake doesn't set /LTCG not set for modules" + echo "Warning: using option /GL exceeds COFF file size of 4G - build will fail" + echo "Warning: cmake doesn't set /LTCG for modules" echo "cmake doesn't set ""Whole Program Optimization"" in project general section either -> must be set manually set CMAKE_CXX_FLAGS="/fp:fast /GL" set CMAKE_LINKER_FLAGS="/LTCG" @@ -61,13 +69,23 @@ if /I %VS_SOLUTION_DIR_NAME%==Debug ( REM explicit /fp:fast build for benchmarking (with macro definitions for Eigen) if /I not x%VS_SOLUTION_DIR_NAME:avx2-fma=%==x%VS_SOLUTION_DIR_NAME% ( set CMAKE_CXX_FLAGS="/fp:fast -D__FMA__ -D__AVX2__" + ) else ( + REM explicit /fp:fast build for benchmarking (with macro definitions for Eigen) + if /I not x%VS_SOLUTION_DIR_NAME:avx2-mkl=%==x%VS_SOLUTION_DIR_NAME% ( + set CMAKE_CXX_FLAGS="/fp:fast -D__FMA__ -D__AVX2__" + set TENSORFLOW_ENABLE_MKL_FLAG=ON + set CMAKE_CXX_FLAGS="-DEIGEN_USE_MKL_ALL" + ) ) ) - - set CMAKE_CONFIGURATION_TYPE=Release ) else ( - set TENSORFLOW_WIN_CPU_SIMD_OPTION="/arch:AVX" - set CMAKE_CONFIGURATION_TYPE=Release + set TENSORFLOW_WIN_CPU_SIMD_OPTION="/arch:AVX" + + if /I not x%VS_SOLUTION_DIR_NAME:-mkl=%==x%VS_SOLUTION_DIR_NAME% ( + set TENSORFLOW_ENABLE_MKL_FLAG=ON + REM set CMAKE_CXX_FLAGS="-DINTEL_MKL -DEIGEN_USE_VML -DENABLE_MKL" + REM set CMAKE_CXX_FLAGS="-DINTEL_MKL -DINTEL_MKL_ML -DEIGEN_USE_MKL_ALL -DMKL_DIRECT_CALL" + ) ) ) @@ -79,14 +97,22 @@ if /I not x%VS_SOLUTION_DIR_NAME:cuda=%==x%VS_SOLUTION_DIR_NAME% ( set TENSORFLOW_BUILD_CC_TESTS_FLAG="OFF" -set CMAKE_DEV_PATH_BUILD=%TENSORFLOW_SOURCES%\cmake_build -set CMAKE_INSTALL_PREFIX="%CMAKE_DEV_PATH_LIB%\tensorflow\%TENSORFLOW_RELEASE%\%TENSORFLOW_VS_BUILD%\%VS_SOLUTION_DIR_NAME%" -set CMAKE_TENSORFLOW_BUILD_PATH=%CMAKE_DEV_PATH_BUILD%\tensorflow\%TENSORFLOW_RELEASE%\%TENSORFLOW_VS_BUILD%\%VS_SOLUTION_DIR_NAME% +set CMAKE_DEV_PATH_BUILD=%TENSORFLOW_SOURCES%\cmake_build\ +set CMAKE_INSTALL_PREFIX=%CMAKE_DEV_PATH_LIB%\tensorflow\%TENSORFLOW_RELEASE%\%TENSORFLOW_VS_BUILD%\%VS_SOLUTION_DIR_NAME%\ +set CMAKE_TENSORFLOW_BUILD_PATH=%CMAKE_DEV_PATH_BUILD%\tensorflow\%TENSORFLOW_RELEASE%\%TENSORFLOW_VS_BUILD%\%VS_SOLUTION_DIR_NAME%\ + + +REM Debug exit +REM exit /B 0 -pushd %TENSORFLOW_SOURCES%\tensorflow\contrib\cmake -cmake . -B%CMAKE_TENSORFLOW_BUILD_PATH% -A x64 ^ --G %CMAKE_GENERATOR% ^ +REM cmake project setup + +pushd %TENSORFLOW_SOURCES%\tensorflow\contrib\cmake\ + +cmake . -B%CMAKE_TENSORFLOW_BUILD_PATH% ^ +-Ax64 ^ +-G%CMAKE_GENERATOR% ^ -DCMAKE_CONFIGURATION_TYPES=%CMAKE_CONFIGURATION_TYPE% ^ -DCMAKE_CXX_FLAGS=%CMAKE_CXX_FLAGS% ^ -DCMAKE_EXE_LINKER_FLAGS=%CMAKE_LINKER_FLAGS% ^ @@ -99,8 +125,8 @@ cmake . -B%CMAKE_TENSORFLOW_BUILD_PATH% -A x64 ^ -Dtensorflow_BUILD_PYTHON_BINDINGS=OFF ^ -Dtensorflow_BUILD_SHARED_LIB=ON ^ -Dtensorflow_DISABLE_EIGEN_FORCEINLINE=OFF ^ --Dtensorflow_ENABLE_MKL_SUPPORT=OFF ^ --Dtensorflow_ENABLE_MKLDNN_SUPPORT=OFF ^ +-Dtensorflow_ENABLE_MKL_SUPPORT=%TENSORFLOW_ENABLE_MKL_FLAG% ^ +-Dtensorflow_ENABLE_MKLDNN_SUPPORT=%TENSORFLOW_ENABLE_MKL_FLAG% ^ -Dtensorflow_ENABLE_GPU=%TENSORFLOW_ENABLE_GPU_FLAG% ^ -Dtensorflow_CUDA_VERSION=10 ^ -Dtensorflow_CUDNN_VERSION=7 ^ @@ -114,6 +140,7 @@ cmake . -B%CMAKE_TENSORFLOW_BUILD_PATH% -A x64 ^ -Dtensorflow_WIN_CPU_SIMD_OPTIONS=%TENSORFLOW_WIN_CPU_SIMD_OPTION% ^ -DCMAKE_INSTALL_PREFIX=%CMAKE_INSTALL_PREFIX% +REM Install mkl from F:\Developer\lib\build\tensorflow_r1.10-cmake\cmake_build\tensorflow\r1.10\vc15\Release-mkl\mkl\bin popd if %errorlevel% neq 0 exit /b %errorlevel% @@ -121,6 +148,9 @@ if %errorlevel% neq 0 exit /b %errorlevel% REM devenv %CMAKE_DEV_PATH_BUILD%\tensorflow\%TENSORFLOW_RELEASE%\%TENSORFLOW_VS_BUILD%\%VS_SOLUTION_DIR_NAME%\Tensorflow.sln REM exit /b 0 + +REM build tensorflow.dll and install lib & includes + MSBuild.exe "%CMAKE_TENSORFLOW_BUILD_PATH%\INSTALL.vcxproj" ^ /verbosity:minimal ^ /p:Configuration=%CMAKE_CONFIGURATION_TYPE% ^ @@ -129,5 +159,16 @@ MSBuild.exe "%CMAKE_TENSORFLOW_BUILD_PATH%\INSTALL.vcxproj" ^ /p:PreferredToolArchitecture=x64 ^ /filelogger +if %errorlevel% neq 0 exit /b %errorlevel% + + +REM Post-processing + +REM Consolidate include files +rmdir /Q /S %CMAKE_INSTALL_PREFIX%..\..\include +move %CMAKE_INSTALL_PREFIX%include %CMAKE_INSTALL_PREFIX%..\..\ if %errorlevel% neq 0 exit /b %errorlevel% + + exit /b 0 + \ No newline at end of file diff --git a/build/cmake environment for x64 build tools.cmd b/build/cmake environment for x64 build tools.cmd deleted file mode 100644 index 0549ff8..0000000 --- a/build/cmake environment for x64 build tools.cmd +++ /dev/null @@ -1,3 +0,0 @@ -REM Setup environmant for cmake - -set PreferredToolArchitecture=x64 diff --git a/build/patches/tensorflow/r1.10/0001-Using-protobuf-3.6.1-to-fix-vs-2017-debug-assertion.patch b/build/patches/tensorflow/r1.10/0001-Using-protobuf-3.6.1-to-fix-vs-2017-debug-assertion.patch new file mode 100644 index 0000000..18e54bd --- /dev/null +++ b/build/patches/tensorflow/r1.10/0001-Using-protobuf-3.6.1-to-fix-vs-2017-debug-assertion.patch @@ -0,0 +1,25 @@ +From e7448859fa45a75b5b5311921e30b8123db704a7 Mon Sep 17 00:00:00 2001 +From: Jens +Date: Sun, 9 Dec 2018 20:05:58 +0100 +Subject: [PATCH 1/2] Using protobuf 3.6.1 to fix vs 2017 debug assertion + +--- + tensorflow/contrib/cmake/external/protobuf.cmake | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tensorflow/contrib/cmake/external/protobuf.cmake b/tensorflow/contrib/cmake/external/protobuf.cmake +index f56fb35a0f..56a57a2340 100644 +--- a/tensorflow/contrib/cmake/external/protobuf.cmake ++++ b/tensorflow/contrib/cmake/external/protobuf.cmake +@@ -16,7 +16,7 @@ include (ExternalProject) + + set(PROTOBUF_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/protobuf/src/protobuf/src) + set(PROTOBUF_URL https://github.com/google/protobuf.git) +-set(PROTOBUF_TAG v3.6.0) ++set(PROTOBUF_TAG v3.6.1) + + if(WIN32) + if(${CMAKE_GENERATOR} MATCHES "Visual Studio.*") +-- +2.16.2.windows.1 + diff --git a/build/patches/tensorflow/r1.10/0002-Fixed-grpc-Configuration-cmake-grpc-was-always-built.patch b/build/patches/tensorflow/r1.10/0002-Fixed-grpc-Configuration-cmake-grpc-was-always-built.patch new file mode 100644 index 0000000..6a25fa8 --- /dev/null +++ b/build/patches/tensorflow/r1.10/0002-Fixed-grpc-Configuration-cmake-grpc-was-always-built.patch @@ -0,0 +1,41 @@ +From 5c7e339a648c2cdbab6bd2558f00b3229976d3f0 Mon Sep 17 00:00:00 2001 +From: Jens +Date: Sun, 9 Dec 2018 12:54:31 +0100 +Subject: [PATCH 2/2] Fixed grpc $(Configuration): cmake grpc was always built + as release configuration + +--- + tensorflow/contrib/cmake/external/grpc.cmake | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/tensorflow/contrib/cmake/external/grpc.cmake b/tensorflow/contrib/cmake/external/grpc.cmake +index b1e64aa55c..188e0391e6 100644 +--- a/tensorflow/contrib/cmake/external/grpc.cmake ++++ b/tensorflow/contrib/cmake/external/grpc.cmake +@@ -26,9 +26,9 @@ if(WIN32) + set(grpc_SSL_PROVIDER NONE) + if(${CMAKE_GENERATOR} MATCHES "Visual Studio.*") + set(grpc_STATIC_LIBRARIES +- ${CMAKE_CURRENT_BINARY_DIR}/grpc/src/grpc/Release/grpc++_unsecure.lib +- ${CMAKE_CURRENT_BINARY_DIR}/grpc/src/grpc/Release/grpc_unsecure.lib +- ${CMAKE_CURRENT_BINARY_DIR}/grpc/src/grpc/Release/gpr.lib) ++ ${CMAKE_CURRENT_BINARY_DIR}/grpc/src/grpc/$(Configuration)/grpc++_unsecure.lib ++ ${CMAKE_CURRENT_BINARY_DIR}/grpc/src/grpc/$(Configuration)/grpc_unsecure.lib ++ ${CMAKE_CURRENT_BINARY_DIR}/grpc/src/grpc/$(Configuration)/gpr.lib) + else() + set(grpc_STATIC_LIBRARIES + ${CMAKE_CURRENT_BINARY_DIR}/grpc/src/grpc/grpc++_unsecure.lib +@@ -57,8 +57,8 @@ ExternalProject_Add(grpc + DOWNLOAD_DIR "${DOWNLOAD_LOCATION}" + BUILD_IN_SOURCE 1 + BUILD_BYPRODUCTS ${grpc_STATIC_LIBRARIES} +- BUILD_COMMAND ${CMAKE_COMMAND} --build . --config Release --target ${grpc_TARGET} +- COMMAND ${CMAKE_COMMAND} --build . --config Release --target grpc_cpp_plugin ++ BUILD_COMMAND ${CMAKE_COMMAND} --build . --config $(Configuration) --target ${grpc_TARGET} ++ COMMAND ${CMAKE_COMMAND} --build . --config $(Configuration) --target grpc_cpp_plugin + INSTALL_COMMAND "" + CMAKE_CACHE_ARGS + -DCMAKE_BUILD_TYPE:STRING=Release +-- +2.16.2.windows.1 + diff --git a/build/patches/tensorflow/r1.13/0001-Fix-Visual-Studio-Debug-build-compile-errors.patch b/build/patches/tensorflow/r1.13/0001-Fix-Visual-Studio-Debug-build-compile-errors.patch new file mode 100644 index 0000000..ce16c0a --- /dev/null +++ b/build/patches/tensorflow/r1.13/0001-Fix-Visual-Studio-Debug-build-compile-errors.patch @@ -0,0 +1,49 @@ +From 0c2a9805389cc681053c185a1e60075fc6ebab37 Mon Sep 17 00:00:00 2001 +From: Jens +Date: Sun, 9 Dec 2018 12:47:53 +0100 +Subject: [PATCH 1/2] 0001 Fix Visual Studio Debug build compile errors + +--- + tensorflow/core/framework/device_base.cc | 5 +++++ + tensorflow/core/framework/op_kernel.h | 2 +- + tensorflow/core/lib/io/path.cc | 1 + + 2 files changed, 6 insertions(+), 0 deletion(-) + +diff --git a/tensorflow/core/framework/device_base.cc b/tensorflow/core/framework/device_base.cc +index 9108c32942..de75c5f052 100644 +--- a/tensorflow/core/framework/device_base.cc ++++ b/tensorflow/core/framework/device_base.cc +@@ -23,14 +23,19 @@ limitations under the License. + + namespace tensorflow { + ++// Workaround "function must return a value" when building on Windows ++const DeviceAttributes* none = nullptr; ++ + DeviceBase::~DeviceBase() { gtl::STLDeleteElements(&eigen_cpu_devices_); } + + const DeviceAttributes& DeviceBase::attributes() const { + LOG(FATAL) << "Device does not implement attributes()"; ++ return *none; + } + + const string& DeviceBase::name() const { + LOG(FATAL) << "Device does not implement name()"; ++ return nullptr; + } + + void DeviceBase::set_eigen_cpu_device(Eigen::ThreadPoolDevice* d) { +diff --git a/tensorflow/core/lib/io/path.cc b/tensorflow/core/lib/io/path.cc +index b75dcecadf..66617847b4 100644 +--- a/tensorflow/core/lib/io/path.cc ++++ b/tensorflow/core/lib/io/path.cc +@@ -287,6 +287,7 @@ string GetTempFilename(const string& extension) { + } + LOG(FATAL) << "No temp directory found."; + #endif ++ return nullptr; + } + + } // namespace io +-- +2.19.1.windows.1 diff --git a/build/patches/tensorflow/r1.13/0002-Fix-Visual-Studio-Debug-build-LNK2019-errors.patch b/build/patches/tensorflow/r1.13/0002-Fix-Visual-Studio-Debug-build-LNK2019-errors.patch new file mode 100644 index 0000000..4ef5e67 --- /dev/null +++ b/build/patches/tensorflow/r1.13/0002-Fix-Visual-Studio-Debug-build-LNK2019-errors.patch @@ -0,0 +1,74 @@ +From 12e1709c1d0ceec0aff401fcf4d2bd2f62a1f458 Mon Sep 17 00:00:00 2001 +From: Jens <31758696+j-o-hemprich@users.noreply.github.com> +Date: Tue, 11 Dec 2018 22:15:45 +0100 +Subject: [PATCH 2/2] Fix Visual Studio Debug build LNK2019 errors + 2017 + +--- + tensorflow/core/kernels/depthtospace_op.cc | 4 ++++ + tensorflow/core/kernels/spacetodepth_op.cc | 4 ++++ + 2 files changed, 8 insertions(+) + +diff --git a/tensorflow/core/kernels/depthtospace_op.cc b/tensorflow/core/kernels/depthtospace_op.cc +index b74a09e2cb..b79f6ffe47 100644 +--- a/tensorflow/core/kernels/depthtospace_op.cc ++++ b/tensorflow/core/kernels/depthtospace_op.cc +@@ -38,7 +38,9 @@ limitations under the License. + namespace tensorflow { + + typedef Eigen::ThreadPoolDevice CPUDevice; ++#if GOOGLE_CUDA + typedef Eigen::GpuDevice GPUDevice; ++#endif // GOOGLE_CUDA + + template + class DepthToSpaceOp : public OpKernel { +@@ -112,6 +114,7 @@ class DepthToSpaceOp : public OpKernel { + auto Tinput = input.tensor(); + auto Toutput = outputs_tensor->tensor(); + ++#if GOOGLE_CUDA + if (std::is_same::value) { + if (is_int8x4) { + // NCHW_VECT_C with 4 x qint8 can be treated as NCHW int32. +@@ -128,6 +131,7 @@ class DepthToSpaceOp : public OpKernel { + return; + } + } ++#endif // GOOGLE_CUDA + + // NOTE: Assumes data_format_ == FORMAT_NHWC here, since we have rejected + // (CPU && data_format_ != FORMAT_NHWC) in the constructor. +diff --git a/tensorflow/core/kernels/spacetodepth_op.cc b/tensorflow/core/kernels/spacetodepth_op.cc +index e59adfc6ac..c62c7b3534 100644 +--- a/tensorflow/core/kernels/spacetodepth_op.cc ++++ b/tensorflow/core/kernels/spacetodepth_op.cc +@@ -38,7 +38,9 @@ limitations under the License. + namespace tensorflow { + + typedef Eigen::ThreadPoolDevice CPUDevice; ++#if GOOGLE_CUDA + typedef Eigen::GpuDevice GPUDevice; ++#endif // GOOGLE_CUDA + + template + class SpaceToDepthOp : public OpKernel { +@@ -114,6 +116,7 @@ class SpaceToDepthOp : public OpKernel { + auto Tinput = input.tensor(); + auto Toutput = outputs_tensor->tensor(); + ++#if GOOGLE_CUDA + if (std::is_same::value) { + if (is_int8x4) { + // NCHW_VECT_C with 4 x qint8 can be treated as NCHW int32. +@@ -130,6 +133,7 @@ class SpaceToDepthOp : public OpKernel { + return; + } + } ++#endif // GOOGLE_CUDA + + // NOTE: Assumes data_format_ == FORMAT_NHWC here, since we have rejected + // (CPU && data_format_ != FORMAT_NHWC) in the constructor. +-- +2.16.2.windows.1 +