Skip to content

Commit

Permalink
Updated cmake build to Visual Studio 2019 & CUDA 10.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Jens committed May 5, 2019
1 parent e82319e commit 8db9985
Show file tree
Hide file tree
Showing 29 changed files with 83 additions and 64 deletions.
3 changes: 3 additions & 0 deletions Deep Learning and Computer Vision libraries.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros" Condition="$(PlatformToolsetVersion)==142">
<VS_VERSION>vc16</VS_VERSION>
</PropertyGroup>
<PropertyGroup Label="UserMacros" Condition="$(PlatformToolsetVersion)==141">
<VS_VERSION>vc15</VS_VERSION>
</PropertyGroup>
Expand Down
19 changes: 14 additions & 5 deletions OpenCV.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,30 @@
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros" />
<PropertyGroup Label="UserMacros" Condition="$(PlatformToolsetVersion)==142">
<OPENCV_TOOLSET_VERSION>vc15</OPENCV_TOOLSET_VERSION>
</PropertyGroup>
<PropertyGroup Label="UserMacros" Condition="$(PlatformToolsetVersion)==141">
<OPENCV_TOOLSET_VERSION>vc15</OPENCV_TOOLSET_VERSION>
</PropertyGroup>
<PropertyGroup Label="UserMacros" Condition="$(PlatformToolsetVersion)==14">
<OPENCV_TOOLSET_VERSION>vc14</OPENCV_TOOLSET_VERSION>
</PropertyGroup>
<PropertyGroup>
<_PropertySheetDisplayName>OpenCV</_PropertySheetDisplayName>
<OPENCV_DIR>$(MSBuildThisFileDirectory)opencv-4.0.1\</OPENCV_DIR>
<ExecutablePath>$(OPENCV_DIR)\build\x64\$(VS_VERSION)\bin\;$(ExecutablePath)</ExecutablePath>
<OPENCV_DIR>$(MSBuildThisFileDirectory)opencv-4.1.0\</OPENCV_DIR>
<ExecutablePath>$(OPENCV_DIR)\build\x64\$(OPENCV_TOOLSET_VERSION)\bin\;$(ExecutablePath)</ExecutablePath>
<IncludePath>$(OPENCV_DIR)\build\include\;$(IncludePath)</IncludePath>
<LibraryPath>$(OPENCV_DIR)\build\x64\$(VS_VERSION)\lib\;$(LibraryPath)</LibraryPath>
<LibraryPath>$(OPENCV_DIR)\build\x64\$(OPENCV_TOOLSET_VERSION)\lib\;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
<Link>
<AdditionalDependencies>opencv_world401d.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>opencv_world410d.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'!='Debug'">
<Link>
<AdditionalDependencies>opencv_world401.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>opencv_world410.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion build/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -259,4 +259,4 @@ paket-files/
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
/cache
*/*/cache
11 changes: 0 additions & 11 deletions build/build_tensorflow_r1.10-cmake-cpu.bat

This file was deleted.

5 changes: 0 additions & 5 deletions build/scripts/cmake_build_config.bat

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.271
# Visual Studio Version 16
VisualStudioVersion = 16.0.28803.202
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloTensorflow", "HelloTensorflow\HelloTensorflow.vcxproj", "{FF1ECE54-D9BC-4A24-86CA-DD63416D2515}"
EndProject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@
<ProjectGuid>{3d84cce1-d54e-46aa-839c-935cc427eb99}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
<Import Project="..\..\..\Deep Learning and Computer Vision libraries.props" />
<Import Project="..\..\..\..\Deep Learning and Computer Vision libraries.props" />
</ImportGroup>
<ImportGroup Label="Shared" />
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
Expand Down Expand Up @@ -68,21 +68,19 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release-cuda-avx2|x64'">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\HelloTensorflow\HelloTensorflow.vcxproj">
<Project>{ff1ece54-d9bc-4a24-86ca-dd63416d2515}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemDefinitionGroup />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\packages\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn.1.8.0\build\native\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn.targets" Condition="Exists('..\packages\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn.1.8.0\build\native\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn.targets')" />
<Import Project="..\..\..\Deep Learning and Computer Vision libraries.targets" />
<Import Project="..\..\..\..\Deep Learning and Computer Vision libraries.targets" />
<Import Project="..\packages\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn.1.8.1\build\native\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn.targets" Condition="Exists('..\packages\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn.1.8.1\build\native\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn.targets')" />
</ImportGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
Expand Down Expand Up @@ -191,6 +189,6 @@
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn.1.8.0\build\native\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn.1.8.0\build\native\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn.targets'))" />
<Error Condition="!Exists('..\packages\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn.1.8.1\build\native\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn.1.8.1\build\native\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn.targets'))" />
</Target>
</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn" version="1.8.0" targetFramework="native" />
<package id="Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn" version="1.8.1" targetFramework="native" />
</packages>
Original file line number Diff line number Diff line change
Expand Up @@ -31,53 +31,53 @@
<ProjectGuid>{FF1ECE54-D9BC-4A24-86CA-DD63416D2515}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>HelloTensorflow</RootNamespace>
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release-cuda|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release-avx2|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release-avx2-fma|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release-cuda-avx2|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
<Import Project="..\..\..\Deep Learning and Computer Vision libraries.props" />
<Import Project="..\..\..\..\Deep Learning and Computer Vision libraries.props" />
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
Expand Down Expand Up @@ -268,6 +268,6 @@
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\..\..\Deep Learning and Computer Vision libraries.targets" />
<Import Project="..\..\..\..\Deep Learning and Computer Vision libraries.targets" />
</ImportGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ call %CMAKE_SCRIPTS%\cmake_build_config.bat
REM Defaults

set ROOT=%~dp0
set BUILD_CACHE=%ROOT%cache\
set BUILD_CACHE=%ROOT%cache

if NOT [%1] == [] (
set VS_SOLUTION_DIR_NAME=%1
Expand All @@ -24,7 +24,7 @@ if NOT [%1] == [] (
if NOT [%2] == [] (
set TENSORFLOW_SOURCES=%2
)else (
set TENSORFLOW_SOURCES=%BUILD_CACHE%tensorflow_%TENSORFLOW_RELEASE%-cmake
set TENSORFLOW_SOURCES=%BUILD_CACHE%\tensorflow_%TENSORFLOW_RELEASE%
)


Expand All @@ -36,8 +36,8 @@ if EXIST "%TENSORFLOW_SOURCES%\.git" (
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
git am --signoff %ROOT%patches\0001-Using-protobuf-3.6.1-to-fix-vs-2017-debug-assertion.patch
git am --signoff %ROOT%patches\0002-Fixed-grpc-Configuration-cmake-grpc-was-always-built.patch
popd
)

Expand Down Expand Up @@ -97,9 +97,8 @@ 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_INSTALL_PREFIX=%CMAKE_DEV_PATH_LIB%\tensorflow\%TENSORFLOW_RELEASE%\%TENSORFLOW_VS_VERSION%\%VS_SOLUTION_DIR_NAME%
set CMAKE_TENSORFLOW_BUILD_PATH=%BUILD_CACHE%\%TENSORFLOW_VS_VERSION%\tensorflow\%TENSORFLOW_RELEASE%\%VS_SOLUTION_DIR_NAME%


REM Debug exit
Expand All @@ -108,7 +107,7 @@ REM exit /B 0

REM cmake project setup

pushd %TENSORFLOW_SOURCES%\tensorflow\contrib\cmake\
pushd %TENSORFLOW_SOURCES%\tensorflow\contrib\cmake

cmake . -B%CMAKE_TENSORFLOW_BUILD_PATH% ^
-Ax64 ^
Expand Down Expand Up @@ -140,12 +139,12 @@ cmake . -B%CMAKE_TENSORFLOW_BUILD_PATH% ^
-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
REM Install mkl from F:\Developer\lib\build\cache\tensorflow\r1.10\vc16\Release-mkl\mkl\bin
popd

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 devenv %CMAKE_TENSORFLOW_BUILD_PATH%\Tensorflow.sln
REM exit /b 0


Expand All @@ -165,10 +164,15 @@ 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%..\..\

rmdir /Q /S %CMAKE_INSTALL_PREFIX%\..\..\include
if %errorlevel% neq 0 exit /b %errorlevel%
move %CMAKE_INSTALL_PREFIX%\include %CMAKE_INSTALL_PREFIX%\..\..\
if %errorlevel% neq 0 (
echo "If you have an Explorer window open close it!"
pause
move %CMAKE_INSTALL_PREFIX%include %CMAKE_INSTALL_PREFIX%\..\..\
if %errorlevel% neq 0 exit /b %errorlevel%
)

exit /b 0

11 changes: 11 additions & 0 deletions build/tensorflow/cmake/build_tensorflow_cpu.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
call build_tensorflow.bat Debug
if %errorlevel% neq 0 exit /b %errorlevel%

call build_tensorflow.bat Release
if %errorlevel% neq 0 exit /b %errorlevel%

call build_tensorflow.bat Release-avx2
if %errorlevel% neq 0 exit /b %errorlevel%

call build_tensorflow.bat Release-avx2-fma
if %errorlevel% neq 0 exit /b %errorlevel%
5 changes: 5 additions & 0 deletions build/tensorflow/cmake/build_tensorflow_cuda.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
call build_tensorflow.bat Release-cuda
if %errorlevel% neq 0 exit /b %errorlevel%

call build_tensorflow.bat Release-cuda-avx2
if %errorlevel% neq 0 exit /b %errorlevel%
5 changes: 5 additions & 0 deletions build/tensorflow/cmake/scripts/cmake_build_config.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
set PreferredToolArchitecture=x64

set TENSORFLOW_RELEASE=r1.10
set TENSORFLOW_VS_VERSION=vc16
set CMAKE_GENERATOR="Visual Studio 16"
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
set CMAKE_DEV_PATH=%~dp0\..\..\..\
set CMAKE_DEV_PATH=%~dp0\..\..\..\..\..\
set CMAKE_DEV_PATH_LIB=%CMAKE_DEV_PATH%\lib
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
set tensorflow_CUDA_VERSION=10.0
set tensorflow_CUDA_VERSION=10.1
set tensorflow_CUDNN_VERSION=7
set CUDA_USE_STATIC_CUDA_RUNTIME=ON
set CUDA_SDK_ROOT_DIR="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA"
set CUDA_TOOLKIT_ROOT_DIR="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.0"
REM cuda hostcompilerdepends on TENSORFLOW_VS_BUILD
set CUDA_HOST_COMPILER="C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64"
set CUDNN_HOME="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.0"
set CUDA_TOOLKIT_ROOT_DIR="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.1"
REM cuda hostcompilerdepends on TENSORFLOW_VS_VERSION
set CUDA_HOST_COMPILER="C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.20.27508\bin\Hostx64\x64"
set CUDNN_HOME="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.1"
Binary file not shown.

0 comments on commit 8db9985

Please sign in to comment.