From a59b6be86a14ba5224fb215ad50eda33497d29e9 Mon Sep 17 00:00:00 2001 From: "Eric St. John" Date: Tue, 21 Aug 2018 13:47:47 -0700 Subject: [PATCH 1/6] Create a redist package for tensorflow Create a nuget package that redistributes the TensorFlow C-API. This is needed because TensorFlow doesn't ship an official NuGet package. This is a straight up repack of the bits published on tensorflow.org. I made sure to apply the TensorFlow license to this package and not sign it with our authenticate certificates. --- build.proj | 9 ++ build/Dependencies.props | 1 + build/sign.proj | 5 +- .../Microsoft.ML.TensorFlow.Redist.nupkgproj | 16 +++ src/Directory.Build.props | 9 ++ src/Native/build.proj | 24 ++-- .../Microsoft.ML.Tensorflow.Redist.proj | 133 ++++++++++++++++++ ...orflow-cpu-darwin-x86_64-1.10.0.tar.gz.sha | 1 + ...sorflow-cpu-linux-x86_64-1.10.0.tar.gz.sha | 1 + ...nsorflow-cpu-windows-x86_64-1.10.0.zip.sha | 1 + src/Redist/build.proj | 6 + 11 files changed, 189 insertions(+), 17 deletions(-) create mode 100644 pkg/Microsoft.ML.TensorFlow.Redist/Microsoft.ML.TensorFlow.Redist.nupkgproj create mode 100644 src/Redist/Microsoft.ML.TensorFlow.Redist/Microsoft.ML.Tensorflow.Redist.proj create mode 100644 src/Redist/Microsoft.ML.TensorFlow.Redist/libtensorflow-cpu-darwin-x86_64-1.10.0.tar.gz.sha create mode 100644 src/Redist/Microsoft.ML.TensorFlow.Redist/libtensorflow-cpu-linux-x86_64-1.10.0.tar.gz.sha create mode 100644 src/Redist/Microsoft.ML.TensorFlow.Redist/libtensorflow-cpu-windows-x86_64-1.10.0.zip.sha create mode 100644 src/Redist/build.proj diff --git a/build.proj b/build.proj index c9be14e930..22aa9588f2 100644 --- a/build.proj +++ b/build.proj @@ -31,6 +31,7 @@ CreateOrUpdateCurrentVersionFile; RestoreProjects; + BuildRedist; BuildNative; $(TraversalBuildDependsOn); DownloadExternalTestFiles; @@ -44,6 +45,14 @@ Properties="MSBuildWarningsAsMessages=NU1503" /> + + + + + diff --git a/build/Dependencies.props b/build/Dependencies.props index 3a46917114..0b6af3cdc9 100644 --- a/build/Dependencies.props +++ b/build/Dependencies.props @@ -11,5 +11,6 @@ 0.0.0.5 4.5.0 0.11.0 + 1.10.0 diff --git a/build/sign.proj b/build/sign.proj index 8f8523474c..498ed7b433 100644 --- a/build/sign.proj +++ b/build/sign.proj @@ -30,7 +30,10 @@ - + + + + Microsoft diff --git a/pkg/Microsoft.ML.TensorFlow.Redist/Microsoft.ML.TensorFlow.Redist.nupkgproj b/pkg/Microsoft.ML.TensorFlow.Redist/Microsoft.ML.TensorFlow.Redist.nupkgproj new file mode 100644 index 0000000000..efb2d6d514 --- /dev/null +++ b/pkg/Microsoft.ML.TensorFlow.Redist/Microsoft.ML.TensorFlow.Redist.nupkgproj @@ -0,0 +1,16 @@ + + + + netstandard2.0 + $(MSBuildProjectName) contains the TensorFlow C library version $(TensorFlowVersion) redistributed as a NuGet package. + https://github.com/tensorflow/tensorflow/blob/master/LICENSE + https://www.tensorflow.org/install/install_c + https://github.com/tensorflow/tensorflow/releases/tag/v$(TensorFlowVersion) + $(PackageTags) TensorFlow + + + + + + + diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 113da3575a..ee32523d8e 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -12,6 +12,15 @@ $(WarningsNotAsErrors);1591 $(MSBuildThisFileDirectory)\Source.ruleset + + x64 + + $(BaseOutputPath)$(TargetArchitecture).$(Configuration)\Native + + win + linux + osx + $(PackageRid)-$(TargetArchitecture) diff --git a/src/Native/build.proj b/src/Native/build.proj index ab338ac855..5e9d7989cb 100644 --- a/src/Native/build.proj +++ b/src/Native/build.proj @@ -3,7 +3,6 @@ true - x64 True @@ -26,21 +25,14 @@ - $(BaseOutputPath)$(TargetArchitecture).$(Configuration)\Native - - lib - .dll - .so - .dylib - - .pdb - .so.dbg - .dylib.dwarf - - win - linux - osx - $(PackageRid)-$(TargetArchitecture) + lib + .dll + .so + .dylib + + .pdb + .so.dbg + .dylib.dwarf + + + netstandard2.0 + + true + false + + + + + + + + + + + + + + + + + + + + + + <_downloadFiles Include="@(TensorFlowArchive)" Url="%(Identity)" DestinationFile="%(DownloadFile)" /> + + + + + + + + + + + + <_filesToCheckSum Include="@(TensorFlowArchive->'%(DownloadFile)')" DestinationPath="%(DownloadShaFile)" /> + + + + + + + + + + + + + + + $([System.IO.File]::ReadAllText('%(LocalShaFile)')) + $([System.IO.File]::ReadAllText('%(DownloadShaFile)')) + + + + + + + + + + + + + + + + + + + + + + + + + + + <_fileFromArchive Include="%(TensorFlowArchive.FilesFromArchive)" ExtractDirectory="%(TensorFlowArchive.ExtractDirectory)" Runtime="%(TensorFlowArchive.Runtime)" /> + <_fileFromArchive DestinationFile="%(FileName)%(Extension)"/> + + <_fileFromArchive Condition="'%(Runtime)' == 'osx-x64'" DestinationFile="%(FileName).dylib" /> + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Redist/Microsoft.ML.TensorFlow.Redist/libtensorflow-cpu-darwin-x86_64-1.10.0.tar.gz.sha b/src/Redist/Microsoft.ML.TensorFlow.Redist/libtensorflow-cpu-darwin-x86_64-1.10.0.tar.gz.sha new file mode 100644 index 0000000000..da8b53866b --- /dev/null +++ b/src/Redist/Microsoft.ML.TensorFlow.Redist/libtensorflow-cpu-darwin-x86_64-1.10.0.tar.gz.sha @@ -0,0 +1 @@ +77218EC4DA96A73B15B8AA5637C9F21B389510A9FAF4DCF06DF5B81A5403015C6BA3EEE29BD8BA5B0694F40C671D8E6722D554C4F93F95C33F29AB491C70263C \ No newline at end of file diff --git a/src/Redist/Microsoft.ML.TensorFlow.Redist/libtensorflow-cpu-linux-x86_64-1.10.0.tar.gz.sha b/src/Redist/Microsoft.ML.TensorFlow.Redist/libtensorflow-cpu-linux-x86_64-1.10.0.tar.gz.sha new file mode 100644 index 0000000000..6b865984ec --- /dev/null +++ b/src/Redist/Microsoft.ML.TensorFlow.Redist/libtensorflow-cpu-linux-x86_64-1.10.0.tar.gz.sha @@ -0,0 +1 @@ +B9E9CD95BC6A28297ACAB0D684FBBFAFF1F9AE893432AC2D208120D767101AC20E2C55BC79E59DBE6E5BD9EC802026694960FA12137BB303061C5A21B62BD29E \ No newline at end of file diff --git a/src/Redist/Microsoft.ML.TensorFlow.Redist/libtensorflow-cpu-windows-x86_64-1.10.0.zip.sha b/src/Redist/Microsoft.ML.TensorFlow.Redist/libtensorflow-cpu-windows-x86_64-1.10.0.zip.sha new file mode 100644 index 0000000000..92ce0db9fb --- /dev/null +++ b/src/Redist/Microsoft.ML.TensorFlow.Redist/libtensorflow-cpu-windows-x86_64-1.10.0.zip.sha @@ -0,0 +1 @@ +66F3A9522917076038AE9CCA11FE805DD516C60B3A3E156B78C2E4BD0E3E5785A9D0380C5E06411473EF14A72B72FD93F954AA3496A12D1FAF0FA3393970E700 \ No newline at end of file diff --git a/src/Redist/build.proj b/src/Redist/build.proj new file mode 100644 index 0000000000..6891516cc0 --- /dev/null +++ b/src/Redist/build.proj @@ -0,0 +1,6 @@ + + + + + + From ee5f0bfe6c5aadcd4927958651bd280f4a4a73fe Mon Sep 17 00:00:00 2001 From: "Eric St. John" Date: Thu, 23 Aug 2018 12:31:07 -0700 Subject: [PATCH 2/6] Make TF redist project a normal MSBuild project Remove the use of the SDK targets, and define our own build and clean. --- .../Microsoft.ML.Tensorflow.Redist.proj | 41 +++++-------------- 1 file changed, 11 insertions(+), 30 deletions(-) diff --git a/src/Redist/Microsoft.ML.TensorFlow.Redist/Microsoft.ML.Tensorflow.Redist.proj b/src/Redist/Microsoft.ML.TensorFlow.Redist/Microsoft.ML.Tensorflow.Redist.proj index db6e9b98ce..3798e6336c 100644 --- a/src/Redist/Microsoft.ML.TensorFlow.Redist/Microsoft.ML.Tensorflow.Redist.proj +++ b/src/Redist/Microsoft.ML.TensorFlow.Redist/Microsoft.ML.Tensorflow.Redist.proj @@ -1,10 +1,8 @@ - + + netstandard2.0 - - true - false @@ -35,9 +33,7 @@ <_downloadFiles Include="@(TensorFlowArchive)" Url="%(Identity)" DestinationFile="%(DownloadFile)" /> - - - + @@ -51,9 +47,6 @@ <_filesToCheckSum Include="@(TensorFlowArchive->'%(DownloadFile)')" DestinationPath="%(DownloadShaFile)" /> - - - - - - - - - - - - - - @@ -119,15 +101,14 @@ - - + DestinationFiles="@(FilesFromArchive->'%(TargetPath)')" /> - - + - - + + + From cba17afd8dd7181dc4e614bc552bd83cfa2c45ca Mon Sep 17 00:00:00 2001 From: "Eric St. John" Date: Thu, 23 Aug 2018 13:28:23 -0700 Subject: [PATCH 3/6] Add TF License file to package --- .../Microsoft.ML.TensorFlow.Redist.nupkgproj | 1 + .../Microsoft.ML.Tensorflow.Redist.proj | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/Microsoft.ML.TensorFlow.Redist/Microsoft.ML.TensorFlow.Redist.nupkgproj b/pkg/Microsoft.ML.TensorFlow.Redist/Microsoft.ML.TensorFlow.Redist.nupkgproj index efb2d6d514..af34bb4f81 100644 --- a/pkg/Microsoft.ML.TensorFlow.Redist/Microsoft.ML.TensorFlow.Redist.nupkgproj +++ b/pkg/Microsoft.ML.TensorFlow.Redist/Microsoft.ML.TensorFlow.Redist.nupkgproj @@ -12,5 +12,6 @@ + diff --git a/src/Redist/Microsoft.ML.TensorFlow.Redist/Microsoft.ML.Tensorflow.Redist.proj b/src/Redist/Microsoft.ML.TensorFlow.Redist/Microsoft.ML.Tensorflow.Redist.proj index 3798e6336c..64c8ae7261 100644 --- a/src/Redist/Microsoft.ML.TensorFlow.Redist/Microsoft.ML.Tensorflow.Redist.proj +++ b/src/Redist/Microsoft.ML.TensorFlow.Redist/Microsoft.ML.Tensorflow.Redist.proj @@ -6,7 +6,7 @@ - + @@ -86,10 +86,14 @@ <_fileFromArchive DestinationFile="%(FileName)%(Extension)"/> <_fileFromArchive Condition="'%(Runtime)' == 'osx-x64'" DestinationFile="%(FileName).dylib" /> + <_fileFromArchive PackagePath="runtimes\%(_fileFromArchive.Runtime)\native\%(_fileFromArchive.DestinationFile)" /> + + + <_fileFromArchive Condition="'%(DestinationFile)' == 'LICENSE'" PackagePath="%(_fileFromArchive.DestinationFile)" Runtime="" /> + TargetPath="$(PackageAssetsPath)$(MSBuildProjectName)\%(_fileFromArchive.PackagePath)" /> Date: Thu, 23 Aug 2018 13:46:07 -0700 Subject: [PATCH 4/6] Don't use fullpaths when un-tar'ing Tar on windows was failing when msbuild passed it a full path. Workaround by using relative paths and running where we extract to. --- .../Microsoft.ML.Tensorflow.Redist.proj | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Redist/Microsoft.ML.TensorFlow.Redist/Microsoft.ML.Tensorflow.Redist.proj b/src/Redist/Microsoft.ML.TensorFlow.Redist/Microsoft.ML.Tensorflow.Redist.proj index 64c8ae7261..f4971ee3a4 100644 --- a/src/Redist/Microsoft.ML.TensorFlow.Redist/Microsoft.ML.Tensorflow.Redist.proj +++ b/src/Redist/Microsoft.ML.TensorFlow.Redist/Microsoft.ML.Tensorflow.Redist.proj @@ -72,8 +72,10 @@ SourceArchive="%(TensorFlowArchive.DownloadFile)" DestinationDirectory="%(TensorFlowArchive.ExtractDirectory)" OverwriteDestination="true" /> + + WorkingDirectory="%(TensorFlowArchive.ExtractDirectory)" + Command="tar -xzmf "$([MSBuild]::MakeRelative('%(TensorFlowArchive.ExtractDirectory)', '%(TensorFlowArchive.DownloadFile)'))"" /> From c7172d6b4e586c1b8c77d48091d1485d14f0c3da Mon Sep 17 00:00:00 2001 From: "Eric St. John" Date: Thu, 23 Aug 2018 16:10:19 -0700 Subject: [PATCH 5/6] Add some logging to TF redist project --- .../Microsoft.ML.Tensorflow.Redist.proj | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Redist/Microsoft.ML.TensorFlow.Redist/Microsoft.ML.Tensorflow.Redist.proj b/src/Redist/Microsoft.ML.TensorFlow.Redist/Microsoft.ML.Tensorflow.Redist.proj index f4971ee3a4..8e4128ec98 100644 --- a/src/Redist/Microsoft.ML.TensorFlow.Redist/Microsoft.ML.Tensorflow.Redist.proj +++ b/src/Redist/Microsoft.ML.TensorFlow.Redist/Microsoft.ML.Tensorflow.Redist.proj @@ -33,6 +33,7 @@ <_downloadFiles Include="@(TensorFlowArchive)" Url="%(Identity)" DestinationFile="%(DownloadFile)" /> + @@ -73,6 +74,7 @@ DestinationDirectory="%(TensorFlowArchive.ExtractDirectory)" OverwriteDestination="true" /> + @@ -106,6 +108,7 @@ + From e0e439d1c13eab5955f7c162d3b422bcca6320cb Mon Sep 17 00:00:00 2001 From: "Eric St. John" Date: Thu, 23 Aug 2018 21:42:38 -0700 Subject: [PATCH 6/6] Fix casing of TF redist proj --- ...Tensorflow.Redist.proj => Microsoft.ML.TensorFlow.Redist.proj} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/Redist/Microsoft.ML.TensorFlow.Redist/{Microsoft.ML.Tensorflow.Redist.proj => Microsoft.ML.TensorFlow.Redist.proj} (100%) diff --git a/src/Redist/Microsoft.ML.TensorFlow.Redist/Microsoft.ML.Tensorflow.Redist.proj b/src/Redist/Microsoft.ML.TensorFlow.Redist/Microsoft.ML.TensorFlow.Redist.proj similarity index 100% rename from src/Redist/Microsoft.ML.TensorFlow.Redist/Microsoft.ML.Tensorflow.Redist.proj rename to src/Redist/Microsoft.ML.TensorFlow.Redist/Microsoft.ML.TensorFlow.Redist.proj