From 1546b4ac003e2ced1811af2db1ca82f0e1f3de35 Mon Sep 17 00:00:00 2001 From: Amine Chadly Date: Thu, 8 Aug 2019 16:39:17 +0200 Subject: [PATCH] Add SciSharp.TensorFlow-Cpu.Redist nuget project. This project can be used to generate a nuget holding tensorflow cpu libraries for windows and linux runtimes. The Copy-NativeTensorFlowLibs.ps1 script can be used to download all the libraries from Google. The examples have been updated to use this nuget to check that things are working. (Make sure to update your package source to have the packages directory in your nuget source before trying this at home). --- TensorFlow.NET.sln | 19 ++++++ scripts/Copy-NativeTensorFlowLibs.ps1 | 44 +++++++++---- .../SciSharp.TensorFlow-Cpu.Redist.csproj | 63 +++++++++++++++++++ .../runtime.json | 14 +++++ ...-x64.SciSharp.TensorFlow-Cpu.Redist.csproj | 39 ++++++++++++ ...-x64.SciSharp.TensorFlow-Cpu.Redist.csproj | 39 ++++++++++++ .../TensorFlowNET.Examples.csproj | 3 +- 7 files changed, 207 insertions(+), 14 deletions(-) create mode 100644 src/SciSharp.TensorFlow-Cpu.Redist/SciSharp.TensorFlow-Cpu.Redist.csproj create mode 100644 src/SciSharp.TensorFlow-Cpu.Redist/runtime.json create mode 100644 src/runtime.linux-x64.SciSharp.TensorFlow-Cpu.Redist/runtime.linux-x64.SciSharp.TensorFlow-Cpu.Redist.csproj create mode 100644 src/runtime.win-x64.SciSharp.TensorFlow-Cpu.Redist/runtime.win-x64.SciSharp.TensorFlow-Cpu.Redist.csproj diff --git a/TensorFlow.NET.sln b/TensorFlow.NET.sln index 487be273..f98a27cb 100644 --- a/TensorFlow.NET.sln +++ b/TensorFlow.NET.sln @@ -22,6 +22,7 @@ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TensorFlowDatasets", "src\TensorFlowDatasets\TensorFlowDatasets.csproj", "{DF151A51-E9FD-41BD-B0F4-08A743755D44}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TensorFlowNET.Examples.GPU", "test\TensorFlowNET.Examples\TensorFlowNET.Examples.GPU.csproj", "{6F6B3382-8F87-4CD9-BF87-C81D5405685A}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scripts", "scripts", "{EA9A238E-B93F-4809-AB3D-339B2990FBFF}" ProjectSection(SolutionItems) = preProject scripts\Copy-NativeTensorFlowLibs.ps1 = scripts\Copy-NativeTensorFlowLibs.ps1 @@ -33,6 +34,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SciSharp.TensorFlow-Gpu.Red EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "runtime.linux-x64.SciSharp.TensorFlow-Gpu.Redist", "src\runtime.linux-x64.SciSharp.TensorFlow-Gpu.Redist\runtime.linux-x64.SciSharp.TensorFlow-Gpu.Redist.csproj", "{E26AA660-F734-444C-A982-3F19C2AF8829}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "runtime.win-x64.SciSharp.TensorFlow-Cpu.Redist", "src\runtime.win-x64.SciSharp.TensorFlow-Cpu.Redist\runtime.win-x64.SciSharp.TensorFlow-Cpu.Redist.csproj", "{54ED61EB-DE05-4052-A92D-15B26478E700}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "runtime.linux-x64.SciSharp.TensorFlow-Cpu.Redist", "src\runtime.linux-x64.SciSharp.TensorFlow-Cpu.Redist\runtime.linux-x64.SciSharp.TensorFlow-Cpu.Redist.csproj", "{977C27F4-2196-4CA4-9A79-80A0F72DBB11}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SciSharp.TensorFlow-Cpu.Redist", "src\SciSharp.TensorFlow-Cpu.Redist\SciSharp.TensorFlow-Cpu.Redist.csproj", "{6AD4A403-2E82-4795-AC61-50D8B271CFC8}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -91,6 +98,18 @@ Global {E26AA660-F734-444C-A982-3F19C2AF8829}.Debug|Any CPU.Build.0 = Debug|Any CPU {E26AA660-F734-444C-A982-3F19C2AF8829}.Release|Any CPU.ActiveCfg = Release|Any CPU {E26AA660-F734-444C-A982-3F19C2AF8829}.Release|Any CPU.Build.0 = Release|Any CPU + {54ED61EB-DE05-4052-A92D-15B26478E700}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {54ED61EB-DE05-4052-A92D-15B26478E700}.Debug|Any CPU.Build.0 = Debug|Any CPU + {54ED61EB-DE05-4052-A92D-15B26478E700}.Release|Any CPU.ActiveCfg = Release|Any CPU + {54ED61EB-DE05-4052-A92D-15B26478E700}.Release|Any CPU.Build.0 = Release|Any CPU + {977C27F4-2196-4CA4-9A79-80A0F72DBB11}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {977C27F4-2196-4CA4-9A79-80A0F72DBB11}.Debug|Any CPU.Build.0 = Debug|Any CPU + {977C27F4-2196-4CA4-9A79-80A0F72DBB11}.Release|Any CPU.ActiveCfg = Release|Any CPU + {977C27F4-2196-4CA4-9A79-80A0F72DBB11}.Release|Any CPU.Build.0 = Release|Any CPU + {6AD4A403-2E82-4795-AC61-50D8B271CFC8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6AD4A403-2E82-4795-AC61-50D8B271CFC8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6AD4A403-2E82-4795-AC61-50D8B271CFC8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6AD4A403-2E82-4795-AC61-50D8B271CFC8}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/scripts/Copy-NativeTensorFlowLibs.ps1 b/scripts/Copy-NativeTensorFlowLibs.ps1 index 2e25b2bf..59f1c37c 100644 --- a/scripts/Copy-NativeTensorFlowLibs.ps1 +++ b/scripts/Copy-NativeTensorFlowLibs.ps1 @@ -7,14 +7,22 @@ The TensorFlow libraries are copied for Windows and Linux and it becomes possible to bundle a meta-package containing them. -.PARAMETER CpuLibraries - Switch indicating if the script should download the CPU or GPU version of the +.PARAMETER SkipCpuLibraries + Setting this to true skips the downloading of the CPU version of the TensorFlow libraries. - By default the GPU version of the libraries is downloaded. + By default the CPU version of the libraries are downloaded and put in the + relevant projects. + +.PARAMETER SkipGpuLibraries + Setting this to tru skips the downloading of the GPU version of the + TensorFlow libraries. + By default the GPU version of the libraries are downloaded and put in the + releavant projects. #> param( - [switch] $CpuLibraries = $false + [switch] $SkipCpuLibraries = $false, + [switch] $SkipGpuLibraries = $false ) function Expand-TarGzFiles { @@ -128,22 +136,32 @@ function Copy-Archive { } $LinuxGpuArchive = "https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-gpu-linux-x86_64-1.14.0.tar.gz" +$LinuxCpuArchive = "https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-linux-x86_64-1.14.0.tar.gz" $LinuxFiles = @(".\libtensorflow.tar", ".\lib\libtensorflow.so", ".\lib\libtensorflow.so.1", ".\lib\libtensorflow.so.1.14.0", ` ".\lib\libtensorflow_framework.so", ".\lib\libtensorflow_framework.so.1", ".\lib\libtensorflow_framework.so.1.14.0") $WindowsGpuArchive = "https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-gpu-windows-x86_64-1.14.0.zip" +$WindowsCpuArchive = "https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-windows-x86_64-1.14.0.zip" $WindowsFiles = @("lib\tensorflow.dll") $PackagesDirectory = [IO.Path]::Combine($PSScriptRoot, "..", "packages") -if (-not $CpuLibraries) { - $WindowsArchive = $WindowsGpuArchive - $LinuxArchive = $LinuxGpuArchive +if (-not $SkipGpuLibraries) { + $Archive = Copy-Archive -ArchiveUrl $WindowsGpuArchive -TargetDirectory $PackagesDirectory + $TargetDirectory = [IO.Path]::Combine($PSScriptRoot, "..", "src", "runtime.win-x64.SciSharp.TensorFlow-Gpu.Redist") + Expand-ZipFiles $Archive $WindowsFiles $TargetDirectory + + $Archive = Copy-Archive -ArchiveUrl $LinuxGpuArchive -TargetDirectory $PackagesDirectory + $TargetDirectory = [IO.Path]::Combine($PSScriptRoot, "..", "src", "runtime.linux-x64.SciSharp.Tensorflow-Gpu.Redist") + Expand-TarGzFiles $Archive $LinuxFiles $TargetDirectory } -$Archive = Copy-Archive -ArchiveUrl $WindowsArchive -TargetDirectory $PackagesDirectory -$TargetDirectory = [IO.Path]::Combine($PSScriptRoot, "..", "src", "runtime.win-x64.SciSharp.TensorFlow-Gpu.Redist") -Expand-ZipFiles $Archive $WindowsFiles $TargetDirectory +if (-not $SkipCpuLibraries) { + $Archive = Copy-Archive -ArchiveUrl $WindowsCpuArchive -TargetDirectory $PackagesDirectory + $TargetDirectory = [IO.Path]::Combine($PSScriptRoot, "..", "src", "runtime.win-x64.SciSharp.TensorFlow-Cpu.Redist") + Expand-ZipFiles $Archive $WindowsFiles $TargetDirectory + + $Archive = Copy-Archive -ArchiveUrl $LinuxCpuArchive -TargetDirectory $PackagesDirectory + $TargetDirectory = [IO.Path]::Combine($PSScriptRoot, "..", "src", "runtime.linux-x64.SciSharp.Tensorflow-Cpu.Redist") + Expand-TarGzFiles $Archive $LinuxFiles $TargetDirectory +} -$Archive = Copy-Archive -ArchiveUrl $LinuxArchive -TargetDirectory $PackagesDirectory -$TargetDirectory = [IO.Path]::Combine($PSScriptRoot, "..", "src", "runtime.linux-x64.SciSharp.Tensorflow-Gpu.Redist") -Expand-TarGzFiles $Archive $LinuxFiles $TargetDirectory diff --git a/src/SciSharp.TensorFlow-Cpu.Redist/SciSharp.TensorFlow-Cpu.Redist.csproj b/src/SciSharp.TensorFlow-Cpu.Redist/SciSharp.TensorFlow-Cpu.Redist.csproj new file mode 100644 index 00000000..4d0fa1f0 --- /dev/null +++ b/src/SciSharp.TensorFlow-Cpu.Redist/SciSharp.TensorFlow-Cpu.Redist.csproj @@ -0,0 +1,63 @@ + + + + netstandard2.0 + win-x64;linux-x64 + SciSharp.Tensorflow-Cpu.Redist + + SciSharp.Tensorflow-Cpu.Redist + 1.0.0 + SciSharp team + SciSharp STACK + https://github.com/SciSharp/TensorFlow.NET + git + + Meta-package for GPU Tensoflow library runtime distribution. + Libraries can be directly downloaded from https://storage.googleapis.com/tensorflow/libtensorflow/ + + Apache-2.0 + + https://github.com/SciSharp/TensorFlow.NET + native;tensorflow;machine-learning;ML + ../../packages + false + + false + false + false + + + + + + + + + + + + + + + + + ../../packages;$(RestoreSources);https://api.nuget.org/v3/index.json + + + + + + + + + + + + + runtime.json + true + PreserveNewest + + + + diff --git a/src/SciSharp.TensorFlow-Cpu.Redist/runtime.json b/src/SciSharp.TensorFlow-Cpu.Redist/runtime.json new file mode 100644 index 00000000..a7a39cb5 --- /dev/null +++ b/src/SciSharp.TensorFlow-Cpu.Redist/runtime.json @@ -0,0 +1,14 @@ +{ + "runtimes": { + "linux-x64": { + "SciSharp.TensorFlow-Gpu.Redist": { + "runtime.linux-x64.SciSharp.Tensorflow-Cpu.Redist": "1.0.0" + } + }, + "win-x64": { + "SciSharp.TensorFlow-Gpu.Redist": { + "runtime.win-x64.SciSharp.Tensorflow-Cpu.Redist": "1.0.0" + } + } + } +} diff --git a/src/runtime.linux-x64.SciSharp.TensorFlow-Cpu.Redist/runtime.linux-x64.SciSharp.TensorFlow-Cpu.Redist.csproj b/src/runtime.linux-x64.SciSharp.TensorFlow-Cpu.Redist/runtime.linux-x64.SciSharp.TensorFlow-Cpu.Redist.csproj new file mode 100644 index 00000000..ea6d4186 --- /dev/null +++ b/src/runtime.linux-x64.SciSharp.TensorFlow-Cpu.Redist/runtime.linux-x64.SciSharp.TensorFlow-Cpu.Redist.csproj @@ -0,0 +1,39 @@ + + + + netstandard2.0 + linux-x64 + SciSharp.Tensorflow-Cpu.Redist + + runtime.linux-x64.SciSharp.Tensorflow-Cpu.Redist + 1.0.0 + SciSharp team + SciSharp STACK + https://github.com/SciSharp/TensorFlow.NET + git + + Distribution of the Linux CPU Tensoflow library. + The libraries can be directly downloaded from https://storage.googleapis.com/tensorflow/libtensorflow/ + + Apache-2.0 + + https://github.com/SciSharp/TensorFlow.NET + native;tensorflow;machine-learning;ML + ../../packages + false + + false + false + false + + + + + + runtimes/$(RuntimeIdentifier)/native/%(Filename)%(Extension) + true + PreserveNewest + + + + diff --git a/src/runtime.win-x64.SciSharp.TensorFlow-Cpu.Redist/runtime.win-x64.SciSharp.TensorFlow-Cpu.Redist.csproj b/src/runtime.win-x64.SciSharp.TensorFlow-Cpu.Redist/runtime.win-x64.SciSharp.TensorFlow-Cpu.Redist.csproj new file mode 100644 index 00000000..19e7854c --- /dev/null +++ b/src/runtime.win-x64.SciSharp.TensorFlow-Cpu.Redist/runtime.win-x64.SciSharp.TensorFlow-Cpu.Redist.csproj @@ -0,0 +1,39 @@ + + + + netstandard2.0 + win-x64 + SciSharp.Tensorflow-Cpu.Redist + + runtime.win-x64.SciSharp.Tensorflow-Cpu.Redist + 1.0.0 + SciSharp team + SciSharp STACK + https://github.com/SciSharp/TensorFlow.NET + git + + Distribution of the windows GPU Tensoflow library. + The libraries can be directly downloaded from https://storage.googleapis.com/tensorflow/libtensorflow/ + + Apache-2.0 + + https://github.com/SciSharp/TensorFlow.NET + native;tensorflow;machine-learning;ML + ../../packages + false + + false + false + false + + + + + + runtimes/$(RuntimeIdentifier)/native/%(Filename)%(Extension) + true + PreserveNewest + + + + diff --git a/test/TensorFlowNET.Examples/TensorFlowNET.Examples.csproj b/test/TensorFlowNET.Examples/TensorFlowNET.Examples.csproj index c675bedc..53a09e5e 100644 --- a/test/TensorFlowNET.Examples/TensorFlowNET.Examples.csproj +++ b/test/TensorFlowNET.Examples/TensorFlowNET.Examples.csproj @@ -13,7 +13,8 @@ - + +