GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — TensorFlow.NET/scripts/Copy-NativeTensorFlowLibs.ps1 at master · lqdev/TensorFlow.NET Expand file tree/ Copy pathCopy-NativeTensorFlowLibs.ps1More file actions 167 lines (131 loc) · 6.27 KB / Copy pathCopy-NativeTensorFlowLibs.ps1File metadata and controls167 lines (131 loc) · 6.27 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 <# .SYNOPSIS Copy the native TensorFlow library to enable the packing a nuget to make them available to TensorFlow.NET .DESCRIPTION The TensorFlow libraries are copied for Windows and Linux and it becomes possible to bundle a meta-package containing them. .PARAMETER SkipCpuLibraries Setting this to true skips the downloading of the CPU version of the TensorFlow libraries. 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] $SkipCpuLibraries = $false, [switch] $SkipGpuLibraries = $false ) function Expand-TarGzFiles { <# .SYNOPSIS Expands the given list of files from the given archive into the given target directory. .PARAMETER Archive Path to the archive that should be considered. .PARAMETER Files Files that should be extracted from the archive. .PARAMETER TargetDirectory Directory into which the files should be expanded. #> param ( [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [string] $Archive, [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [string []] $Files, [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [string] $TargetDirectory ) & 7z e $Archive -o"$TargetDirectory" $TarArchive = Join-Path $TargetDirectory "libtensorflow.tar" & 7z e $TarArchive $Files -o"$TargetDirectory" Remove-Item $TarArchive } function Expand-ZipFiles { <# .SYNOPSIS Expands the given list of files from the given archive into the given target directory. .PARAMETER Archive Path to the archive that should be considered. .PARAMETER Files Files that should be extracted from the archive. .PARAMETER TargetDirectory Directory into which the files should be expanded. #> param( [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [string] $Archive, [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [string []] $Files, [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [string] $TargetDirectory ) & 7z e $Archive $Files -o"$TargetDirectory" } function Split-ArchiveFromUrl { <# .SYNOPSIS Extracts the archive name out of the given Url. .PARAMETER ArchiveUrl Url of the archive that will be downloaded. #> param( [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [string] $ArchiveUrl ) $uriParts = $ArchiveUrl.split("/") $ArchivePath = $uriParts[$uriParts.Count - 1] return $ArchivePath } function Copy-Archive { <# .SYNOPSIS This function copies the given binary file to the given target location. .PARAMETER ArchiveUrl Url where the archive should be downloaded from. .PARAMETER TargetDirectory Target directory where the archive should be downloaded. #> param ( [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [string] $ArchiveUrl, [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [string] $TargetDirectory ) $ArchiveName = Split-ArchiveFromUrl $ArchiveUrl $TargetPath = [IO.Path]::Combine($PSScriptRoot, "..", "packages", $ArchiveName) if (Test-Path $TargetPath -PathType Leaf) { Write-Error "$TargetPath already exists, please remove to download againg." return $TargetPath } if (-not (Test-Path $TargetDirectory -PathType Container)) { Write-Host "Creating missing $TargetDirectory" New-Item -Path $TargetDirectory -ItemType Directory } Write-Host "Downloading $ArchiveUrl, this might take a while..." $wc = New-Object System.Net.WebClient $wc.DownloadFile($ArchiveUrl, $TargetPath) return $TargetPath } $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 $SkipGpuLibraries) { $Archive = Copy-Archive -ArchiveUrl $WindowsGpuArchive -TargetDirectory $PackagesDirectory $TargetDirectory = [IO.Path]::Combine($PSScriptRoot, "..", "redist", "runtime.win-x64.SciSharp.TensorFlow-Gpu.Redist") Expand-ZipFiles $Archive $WindowsFiles $TargetDirectory $Archive = Copy-Archive -ArchiveUrl $LinuxGpuArchive -TargetDirectory $PackagesDirectory $TargetDirectory = [IO.Path]::Combine($PSScriptRoot, "..", "redist", "runtime.linux-x64.SciSharp.Tensorflow-Gpu.Redist") Expand-TarGzFiles $Archive $LinuxFiles $TargetDirectory } if (-not $SkipCpuLibraries) { $Archive = Copy-Archive -ArchiveUrl $WindowsCpuArchive -TargetDirectory $PackagesDirectory $TargetDirectory = [IO.Path]::Combine($PSScriptRoot, "..", "redist", "runtime.win-x64.SciSharp.TensorFlow-Cpu.Redist") Expand-ZipFiles $Archive $WindowsFiles $TargetDirectory $Archive = Copy-Archive -ArchiveUrl $LinuxCpuArchive -TargetDirectory $PackagesDirectory $TargetDirectory = [IO.Path]::Combine($PSScriptRoot, "..", "redist", "runtime.linux-x64.SciSharp.Tensorflow-Cpu.Redist") Expand-TarGzFiles $Archive $LinuxFiles $TargetDirectory } |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |