1
+ # ***************************************
2
+ # Arguments
3
+ # %1: CUDA (92,100,101,102,110,111)
4
+ # ***************************************
5
+ Param ([Parameter (
6
+ Mandatory = $True ,
7
+ Position = 1
8
+ )][string ]
9
+ $CUDA
10
+ )
11
+
12
+ Set-StrictMode - Version Latest
13
+
14
+ # For windows
15
+
16
+ # For DlibDotNet.CUDA92
17
+ $tmp92 = New-Object ' System.Collections.Generic.List[string]'
18
+ $tmp92.Add (" $env: CUDA_PATH_V9_2 \bin\cublas64_92.dll" )
19
+ $tmp92.Add (" $env: CUDA_PATH_V9_2 \bin\cudnn64_7.dll" )
20
+ $tmp92.Add (" $env: CUDA_PATH_V9_2 \bin\curand64_92.dll" )
21
+ $tmp92.Add (" $env: CUDA_PATH_V9_2 \bin\cusolver64_92.dll" )
22
+
23
+ # For DlibDotNet.CUDA100
24
+ $tmp100 = New-Object ' System.Collections.Generic.List[string]'
25
+ $tmp100.Add (" $env: CUDA_PATH_V10_0 \bin\cublas64_100.dll" )
26
+ $tmp100.Add (" $env: CUDA_PATH_V10_0 \bin\cudnn64_7.dll" )
27
+ $tmp100.Add (" $env: CUDA_PATH_V10_0 \bin\curand64_100.dll" )
28
+ $tmp100.Add (" $env: CUDA_PATH_V10_0 \bin\cusolver64_100.dll" )
29
+
30
+ # For DlibDotNet.CUDA101
31
+ $tmp101 = New-Object ' System.Collections.Generic.List[string]'
32
+ $tmp101.Add (" $env: CUDA_PATH_V10_1 \bin\cublas64_10.dll" )
33
+ $tmp101.Add (" $env: CUDA_PATH_V10_1 \bin\cudnn64_7.dll" )
34
+ $tmp101.Add (" $env: CUDA_PATH_V10_1 \bin\curand64_10.dll" )
35
+ $tmp101.Add (" $env: CUDA_PATH_V10_1 \bin\cusolver64_10.dll" )
36
+
37
+ # For DlibDotNet.CUDA102
38
+ $tmp102 = New-Object ' System.Collections.Generic.List[string]'
39
+ $tmp102.Add (" $env: CUDA_PATH_V10_2 \bin\cublas64_10.dll" )
40
+ $tmp102.Add (" $env: CUDA_PATH_V10_2 \bin\cudnn64_7.dll" )
41
+ $tmp102.Add (" $env: CUDA_PATH_V10_2 \bin\curand64_10.dll" )
42
+ $tmp102.Add (" $env: CUDA_PATH_V10_2 \bin\cusolver64_10.dll" )
43
+
44
+ # For DlibDotNet.CUDA110
45
+ $tmp110 = New-Object ' System.Collections.Generic.List[string]'
46
+ $tmp110.Add (" $env: CUDA_PATH_V11_0 \bin\cublas64_11.dll" )
47
+ $tmp110.Add (" $env: CUDA_PATH_V11_0 \bin\cublasLt64_11.dll" )
48
+ $tmp110.Add (" $env: CUDA_PATH_V11_0 \bin\cudnn_adv_infer64_8.dll" )
49
+ $tmp110.Add (" $env: CUDA_PATH_V11_0 \bin\cudnn_adv_train64_8.dll" )
50
+ $tmp110.Add (" $env: CUDA_PATH_V11_0 \bin\cudnn_cnn_infer64_8.dll" )
51
+ $tmp110.Add (" $env: CUDA_PATH_V11_0 \bin\cudnn_cnn_train64_8.dll" )
52
+ $tmp110.Add (" $env: CUDA_PATH_V11_0 \bin\cudnn_ops_infer64_8.dll" )
53
+ $tmp110.Add (" $env: CUDA_PATH_V11_0 \bin\cudnn_ops_train64_8.dll" )
54
+ $tmp110.Add (" $env: CUDA_PATH_V11_0 \bin\cudnn64_8.dll" )
55
+ $tmp110.Add (" $env: CUDA_PATH_V11_0 \bin\curand64_10.dll" )
56
+ $tmp110.Add (" $env: CUDA_PATH_V11_0 \bin\cusolver64_10.dll" )
57
+
58
+ # For DlibDotNet.CUDA111
59
+ $tmp111 = New-Object ' System.Collections.Generic.List[string]'
60
+ $tmp111.Add (" $env: CUDA_PATH_V11_1 \bin\cublas64_11.dll" )
61
+ $tmp111.Add (" $env: CUDA_PATH_V11_1 \bin\cublasLt64_11.dll" )
62
+ $tmp111.Add (" $env: CUDA_PATH_V11_1 \bin\cudnn_adv_infer64_8.dll" )
63
+ $tmp111.Add (" $env: CUDA_PATH_V11_1 \bin\cudnn_adv_train64_8.dll" )
64
+ $tmp111.Add (" $env: CUDA_PATH_V11_1 \bin\cudnn_cnn_infer64_8.dll" )
65
+ $tmp111.Add (" $env: CUDA_PATH_V11_1 \bin\cudnn_cnn_train64_8.dll" )
66
+ $tmp111.Add (" $env: CUDA_PATH_V11_1 \bin\cudnn_ops_infer64_8.dll" )
67
+ $tmp111.Add (" $env: CUDA_PATH_V11_1 \bin\cudnn_ops_train64_8.dll" )
68
+ $tmp111.Add (" $env: CUDA_PATH_V11_1 \bin\cudnn64_8.dll" )
69
+ $tmp111.Add (" $env: CUDA_PATH_V11_1 \bin\curand64_10.dll" )
70
+ $tmp111.Add (" $env: CUDA_PATH_V11_1 \bin\cusolver64_11.dll" )
71
+
72
+ $BuildTargets = @ ()
73
+ $BuildTargets += New-Object PSObject - Property @ {Package = " 92" ; Dependencies = $tmp92 }
74
+ $BuildTargets += New-Object PSObject - Property @ {Package = " 100" ; Dependencies = $tmp100 }
75
+ $BuildTargets += New-Object PSObject - Property @ {Package = " 101" ; Dependencies = $tmp101 }
76
+ $BuildTargets += New-Object PSObject - Property @ {Package = " 102" ; Dependencies = $tmp102 }
77
+ $BuildTargets += New-Object PSObject - Property @ {Package = " 110" ; Dependencies = $tmp110 }
78
+ $BuildTargets += New-Object PSObject - Property @ {Package = " 111" ; Dependencies = $tmp111 }
79
+
80
+ # Store current directory
81
+ $DlibDotNetRoot = $PSScriptRoot
82
+
83
+ $Libraries = $Null
84
+ foreach ($Target in $BuildTargets )
85
+ {
86
+ if ($Target.Package -eq $CUDA )
87
+ {
88
+ $Libraries = $Target.Dependencies
89
+ break
90
+ }
91
+ }
92
+
93
+ if ($Libraries -eq $Null )
94
+ {
95
+ Write-Host " ${CUDA} is invalid parameter" - ForegroundColor Red
96
+ exit
97
+ }
98
+
99
+ $BuildConfiguration = " Release"
100
+
101
+ $BuildLibraryWindowsHash =
102
+ @ {
103
+ " DlibDotNet.Native" = (Join-Path $BuildConfiguration " DlibDotNetNative.dll" );
104
+ " DlibDotNet.Native.Dnn" = (Join-Path $BuildConfiguration " DlibDotNetNativeDnn.dll" )
105
+ }
106
+
107
+ $SourceDir = Join-Path $DlibDotNetRoot src
108
+ $BuildDir = " build_win_desktop_cuda-${CUDA} _x64"
109
+
110
+ $Files = Get-ChildItem - Recurse - Name - include * .csproj
111
+
112
+ $re = New-Object regex(" <TargetFramework>(?<Version>[^<]+)</TargetFramework>" )
113
+ foreach ($File in $Files )
114
+ {
115
+ $ProjectRoot = Split-Path ${file} - Parent
116
+ $ProjectRoot = Join-Path ${DlibDotNetRoot} ${ProjectRoot}
117
+
118
+ # check framework version
119
+ $ProjectFile = Get-Content ${file}
120
+ $Match = $re.Matches (${ProjectFile} )
121
+ if ($Match -ne $Null )
122
+ {
123
+ $Version = $Match.Groups [1 ].Value
124
+
125
+ $Configurations = @ ( " Release" , " Debug" )
126
+ foreach ($Configuration in $Configurations )
127
+ {
128
+ $TargetDir = Join-Path $ProjectRoot bin | `
129
+ Join-Path - ChildPath $Configuration | `
130
+ Join-Path - ChildPath $Version
131
+
132
+ if (! (Test-Path $TargetDir ))
133
+ {
134
+ New-Item $TargetDir - ItemType Directory | Out-Null
135
+ }
136
+
137
+ foreach ($Library in $Libraries )
138
+ {
139
+ $FileName = Split-Path $Library - Leaf
140
+ $FilePath = Join-Path $TargetDir $FileName
141
+
142
+ if ((Test-Path $FilePath ))
143
+ {
144
+ Remove-Item $FilePath
145
+ }
146
+
147
+ New-Item - Value " $Library " - Path " $TargetDir " - Name " $FileName " - ItemType SymbolicLink > $null
148
+ }
149
+
150
+ foreach ($key in $BuildLibraryWindowsHash.keys )
151
+ {
152
+ $SrcDir = Join-Path $SourceDir $key | `
153
+ Join-Path - ChildPath $BuildDir
154
+ $Dll = $BuildLibraryWindowsHash [$key ]
155
+ $FileName = Split-Path $Dll - Leaf
156
+ $FilePath = Join-Path $TargetDir $FileName
157
+ $Library = Join-Path $SrcDir $Dll
158
+
159
+ if ((Test-Path $FilePath ))
160
+ {
161
+ Remove-Item $FilePath
162
+ }
163
+
164
+ New-Item - Value " $Library " - Path " $TargetDir " - Name " $FileName " - ItemType SymbolicLink > $null
165
+ }
166
+ }
167
+ }
168
+ }
169
+
170
+ # Move to Root directory
171
+ Set-Location - Path $DlibDotNetRoot
0 commit comments