-
Notifications
You must be signed in to change notification settings - Fork 136
/
CreateSymlink.ps1
171 lines (144 loc) · 6.32 KB
/
CreateSymlink.ps1
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
167
168
169
170
171
#***************************************
#Arguments
#%1: CUDA (92,100,101,102,110,111)
#***************************************
Param([Parameter(
Mandatory=$True,
Position = 1
)][string]
$CUDA
)
Set-StrictMode -Version Latest
# For windows
# For DlibDotNet.CUDA92
$tmp92 = New-Object 'System.Collections.Generic.List[string]'
$tmp92.Add("$env:CUDA_PATH_V9_2\bin\cublas64_92.dll")
$tmp92.Add("$env:CUDA_PATH_V9_2\bin\cudnn64_7.dll")
$tmp92.Add("$env:CUDA_PATH_V9_2\bin\curand64_92.dll")
$tmp92.Add("$env:CUDA_PATH_V9_2\bin\cusolver64_92.dll")
# For DlibDotNet.CUDA100
$tmp100 = New-Object 'System.Collections.Generic.List[string]'
$tmp100.Add("$env:CUDA_PATH_V10_0\bin\cublas64_100.dll")
$tmp100.Add("$env:CUDA_PATH_V10_0\bin\cudnn64_7.dll")
$tmp100.Add("$env:CUDA_PATH_V10_0\bin\curand64_100.dll")
$tmp100.Add("$env:CUDA_PATH_V10_0\bin\cusolver64_100.dll")
# For DlibDotNet.CUDA101
$tmp101 = New-Object 'System.Collections.Generic.List[string]'
$tmp101.Add("$env:CUDA_PATH_V10_1\bin\cublas64_10.dll")
$tmp101.Add("$env:CUDA_PATH_V10_1\bin\cudnn64_7.dll")
$tmp101.Add("$env:CUDA_PATH_V10_1\bin\curand64_10.dll")
$tmp101.Add("$env:CUDA_PATH_V10_1\bin\cusolver64_10.dll")
# For DlibDotNet.CUDA102
$tmp102 = New-Object 'System.Collections.Generic.List[string]'
$tmp102.Add("$env:CUDA_PATH_V10_2\bin\cublas64_10.dll")
$tmp102.Add("$env:CUDA_PATH_V10_2\bin\cudnn64_7.dll")
$tmp102.Add("$env:CUDA_PATH_V10_2\bin\curand64_10.dll")
$tmp102.Add("$env:CUDA_PATH_V10_2\bin\cusolver64_10.dll")
# For DlibDotNet.CUDA110
$tmp110 = New-Object 'System.Collections.Generic.List[string]'
$tmp110.Add("$env:CUDA_PATH_V11_0\bin\cublas64_11.dll")
$tmp110.Add("$env:CUDA_PATH_V11_0\bin\cublasLt64_11.dll")
$tmp110.Add("$env:CUDA_PATH_V11_0\bin\cudnn_adv_infer64_8.dll")
$tmp110.Add("$env:CUDA_PATH_V11_0\bin\cudnn_adv_train64_8.dll")
$tmp110.Add("$env:CUDA_PATH_V11_0\bin\cudnn_cnn_infer64_8.dll")
$tmp110.Add("$env:CUDA_PATH_V11_0\bin\cudnn_cnn_train64_8.dll")
$tmp110.Add("$env:CUDA_PATH_V11_0\bin\cudnn_ops_infer64_8.dll")
$tmp110.Add("$env:CUDA_PATH_V11_0\bin\cudnn_ops_train64_8.dll")
$tmp110.Add("$env:CUDA_PATH_V11_0\bin\cudnn64_8.dll")
$tmp110.Add("$env:CUDA_PATH_V11_0\bin\curand64_10.dll")
$tmp110.Add("$env:CUDA_PATH_V11_0\bin\cusolver64_10.dll")
# For DlibDotNet.CUDA111
$tmp111 = New-Object 'System.Collections.Generic.List[string]'
$tmp111.Add("$env:CUDA_PATH_V11_1\bin\cublas64_11.dll")
$tmp111.Add("$env:CUDA_PATH_V11_1\bin\cublasLt64_11.dll")
$tmp111.Add("$env:CUDA_PATH_V11_1\bin\cudnn_adv_infer64_8.dll")
$tmp111.Add("$env:CUDA_PATH_V11_1\bin\cudnn_adv_train64_8.dll")
$tmp111.Add("$env:CUDA_PATH_V11_1\bin\cudnn_cnn_infer64_8.dll")
$tmp111.Add("$env:CUDA_PATH_V11_1\bin\cudnn_cnn_train64_8.dll")
$tmp111.Add("$env:CUDA_PATH_V11_1\bin\cudnn_ops_infer64_8.dll")
$tmp111.Add("$env:CUDA_PATH_V11_1\bin\cudnn_ops_train64_8.dll")
$tmp111.Add("$env:CUDA_PATH_V11_1\bin\cudnn64_8.dll")
$tmp111.Add("$env:CUDA_PATH_V11_1\bin\curand64_10.dll")
$tmp111.Add("$env:CUDA_PATH_V11_1\bin\cusolver64_11.dll")
$BuildTargets = @()
$BuildTargets += New-Object PSObject -Property @{Package = "92"; Dependencies = $tmp92 }
$BuildTargets += New-Object PSObject -Property @{Package = "100"; Dependencies = $tmp100 }
$BuildTargets += New-Object PSObject -Property @{Package = "101"; Dependencies = $tmp101 }
$BuildTargets += New-Object PSObject -Property @{Package = "102"; Dependencies = $tmp102 }
$BuildTargets += New-Object PSObject -Property @{Package = "110"; Dependencies = $tmp110 }
$BuildTargets += New-Object PSObject -Property @{Package = "111"; Dependencies = $tmp111 }
# Store current directory
$DlibDotNetRoot = $PSScriptRoot
$Libraries = $Null
foreach ($Target in $BuildTargets)
{
if ($Target.Package -eq $CUDA)
{
$Libraries = $Target.Dependencies
break
}
}
if ($Libraries -eq $Null)
{
Write-Host "${CUDA} is invalid parameter" -ForegroundColor Red
exit
}
$BuildConfiguration = "Release"
$BuildLibraryWindowsHash =
@{
"DlibDotNet.Native" = (Join-Path $BuildConfiguration "DlibDotNetNative.dll");
"DlibDotNet.Native.Dnn" = (Join-Path $BuildConfiguration "DlibDotNetNativeDnn.dll")
}
$SourceDir = Join-Path $DlibDotNetRoot src
$BuildDir = "build_win_desktop_cuda-${CUDA}_x64"
$Files = Get-ChildItem -Recurse -Name -include *.csproj
$re = New-Object regex("<TargetFramework>(?<Version>[^<]+)</TargetFramework>")
foreach ($File in $Files)
{
$ProjectRoot = Split-Path ${file} -Parent
$ProjectRoot = Join-Path ${DlibDotNetRoot} ${ProjectRoot}
# check framework version
$ProjectFile = Get-Content ${file}
$Match = $re.Matches(${ProjectFile})
if ($Match -ne $Null)
{
$Version = $Match.Groups[1].Value
$Configurations = @( "Release", "Debug" )
foreach ($Configuration in $Configurations)
{
$TargetDir = Join-Path $ProjectRoot bin | `
Join-Path -ChildPath $Configuration | `
Join-Path -ChildPath $Version
if (!(Test-Path $TargetDir))
{
New-Item $TargetDir -ItemType Directory | Out-Null
}
foreach ($Library in $Libraries)
{
$FileName = Split-Path $Library -Leaf
$FilePath = Join-Path $TargetDir $FileName
if ((Test-Path $FilePath))
{
Remove-Item $FilePath
}
New-Item -Value "$Library" -Path "$TargetDir" -Name "$FileName" -ItemType SymbolicLink > $null
}
foreach ($key in $BuildLibraryWindowsHash.keys)
{
$SrcDir = Join-Path $SourceDir $key | `
Join-Path -ChildPath $BuildDir
$Dll = $BuildLibraryWindowsHash[$key]
$FileName = Split-Path $Dll -Leaf
$FilePath = Join-Path $TargetDir $FileName
$Library = Join-Path $SrcDir $Dll
if ((Test-Path $FilePath))
{
Remove-Item $FilePath
}
New-Item -Value "$Library" -Path "$TargetDir" -Name "$FileName" -ItemType SymbolicLink > $null
}
}
}
}
# Move to Root directory
Set-Location -Path $DlibDotNetRoot