forked from pytorch/test-infra
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstall-CUDA-Tools.ps1
More file actions
139 lines (118 loc) · 6.38 KB
/
Copy pathInstall-CUDA-Tools.ps1
File metadata and controls
139 lines (118 loc) · 6.38 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
param(
[string] $cudaVersion = $env:CUDA_VERSION
)
function New-TemporaryDirectory() {
New-TemporaryFile | ForEach-Object { Remove-Item $_; New-Item -ItemType Directory -Path $_ }
}
$windowsS3BaseUrl = "https://ossci-windows.s3.amazonaws.com"
$ProgressPreference = 'SilentlyContinue'
# installerArgs
$installerArgs = "nvcc_$cudaVersion cuobjdump_$cudaVersion nvprune_$cudaVersion nvprof_$cudaVersion cupti_$cudaVersion cublas_$cudaVersion cublas_dev_$cudaVersion cudart_$cudaVersion cufft_$cudaVersion cufft_dev_$cudaVersion curand_$cudaVersion curand_dev_$cudaVersion cusolver_$cudaVersion cusolver_dev_$cudaVersion cusparse_$cudaVersion cusparse_dev_$cudaVersion npp_$cudaVersion npp_dev_$cudaVersion nvrtc_$cudaVersion nvrtc_dev_$cudaVersion nvml_dev_$cudaVersion nvjpeg_$cudaVersion nvjpeg_dev_$cudaVersion"
# Switch statement for specfic CUDA versions
$cudnn_subfolder="cuda"
$cudnn_lib_folder="lib\x64"
$cudnn_subfolder="cudnn-windows-x86_64-9.10.2.21_cuda12-archive"
$toolkitInstaller = "cuda_12.6.3_561.17_windows.exe"
Switch ($cudaVersion) {
"12.6" {
$toolkitInstaller = "cuda_12.6.3_561.17_windows.exe"
$installerArgs += " cuda_profiler_api_$cudaVersion nvjitlink_$cudaVersion"
}
"12.8" {
$toolkitInstaller = "cuda_12.8.1_572.61_windows.exe"
$installerArgs += " cuda_profiler_api_$cudaVersion nvjitlink_$cudaVersion"
}
"12.9" {
$toolkitInstaller = "cuda_12.9.1_576.57_windows.exe"
$installerArgs += " cuda_profiler_api_$cudaVersion nvjitlink_$cudaVersion"
}
"13.0" {
$toolkitInstaller = "cuda_13.0.0_windows.exe"
$installerArgs += " cuda_profiler_api_$cudaVersion nvjitlink_$cudaVersion"
}
}
$cudnnZip = "$cudnn_subfolder.zip"
$installerArgs = "$installerArgs thrust_$cudaVersion"
$cudnn_lib_folder="lib"
Write-Output "Downloading ZLIB DLL, $windowsS3BaseUrl/zlib123dllx64.zip"
$tmpZlibDll = New-TemporaryFile
Invoke-WebRequest -Uri "$windowsS3BaseUrl/zlib123dllx64.zip" -OutFile "$tmpZlibDll"
$tmpExtractedZlibDll = New-TemporaryDirectory
7z x "$tmpZlibDll" -o"$tmpExtractedZlibDll"
Get-ChildItem -Path $tmpExtractedZlibDll
if (-Not (Test-Path -Path "$tmpExtractedZlibDll\dll_x64\zlibwapi.dll" -PathType Leaf)) {
Write-Error "zlib installation failed $tmpExtractedZlibDll\dll_x64\zlibwapi.dll"
exit 1
}
Copy-Item -Force -Verbose -Recurse "$tmpExtractedZlibDll\dll_x64\zlibwapi.dll" "c:\windows\system32\"
function Install-CudaToolkit() {
$expectedInstallLocation = "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v$cudaVersion"
if (Test-Path -Path "$expectedInstallLocation\bin\nvcc.exe" -PathType Leaf) {
Write-Output "Existing cudatoolkit installation already found at '$expectedInstallLocation', continuing..."
return
}
Write-Output "Downloading toolkit installer, $windowsS3BaseUrl/$toolkitInstaller"
$tmpToolkitInstaller = New-TemporaryFile
Invoke-WebRequest -Uri "$windowsS3BaseUrl/$toolkitInstaller" -OutFile "$tmpToolkitInstaller"
$tmpExtractedInstaller = New-TemporaryDirectory
7z x "$tmpToolkitInstaller" -o"$tmpExtractedInstaller"
$cudaInstallLogs = New-TemporaryDirectory
Write-Output "Running installer for CUDA v$cudaVersion..."
$argsList = "-s $installerArgs -loglevel:6 -log:$cudaInstallLogs"
Write-Output "setup.exe: $tmpExtractedInstaller\setup.exe"
Write-Output "Args: $argsList"
Start-Process -FilePath "$tmpExtractedInstaller\setup.exe" -ArgumentList "$argsList" -Wait -NoNewWindow -PassThru
if (-Not (Test-Path -Path "$expectedInstallLocation\bin\nvcc.exe" -PathType Leaf)) {
Write-Error "CUDA installation failed for CUDA version $cudaVersion, nvcc not found at $expectedInstallLocation\bin\nvcc.exe"
Write-Error "==== LOG.RunDll32.exe.log ===="
Get-Content -Path "$cudaInstallLogs\LOG.RunDll32.exe.log"
Write-Error "==== Log.setup.exe.log ===="
Get-Content -Path "$cudaInstallLogs\LOG.setup.exe.log"
exit 1
}
Write-Output "Installing VS 2019 integration"
New-Item -Path "$expectedInstallLocation\MSBuildExtensions\" -Type Directory -Force
Copy-Item -Force -Verbose -Recurse "$tmpExtractedInstaller\visual_studio_integration\CUDAVisualStudioIntegration\extras\visual_studio_integration\MSBuildExtensions\*.*" "$expectedInstallLocation\MSBuildExtensions\"
}
function Install-Cudnn() {
$expectedInstallLocation = "$env:ProgramFiles\NVIDIA GPU Computing Toolkit\CUDA\v$cudaVersion\"
if (Test-Path -Path "$expectedInstallLocation\include\cudnn.h" -PathType Leaf) {
Write-Output "Existing cudnn installation already found at '$expectedInstallLocation', continuing..."
return
}
Write-Output "Downloading cudnnArchive, $windowsS3BaseUrl/$cudnnZip"
$tmpCudnnInstall = New-TemporaryFile
Invoke-WebRequest -Uri "$windowsS3BaseUrl/$cudnnZip" -OutFile "$tmpCudnnInstall"
$tmpCudnnExtracted = New-TemporaryDirectory
7z x "$tmpCudnnInstall" -o"$tmpCudnnExtracted"
Write-Output "Copying cudnn to $expectedInstallLocation"
Copy-Item -Force -Verbose -Recurse "$tmpCudnnExtracted\$cudnn_subfolder\bin\*" "$expectedInstallLocation\bin"
Copy-Item -Force -Verbose -Recurse "$tmpCudnnExtracted\$cudnn_subfolder\$cudnn_lib_folder\x64\*" "$expectedInstallLocation\lib\x64"
Copy-Item -Force -Verbose -Recurse "$tmpCudnnExtracted\$cudnn_subfolder\include\*" "$expectedInstallLocation\include"
if (-Not (Test-Path -Path "$expectedInstallLocation\include\cudnn.h" -PathType Leaf)) {
Write-Error "cudnn installation failed for CUDA version $cudaVersion, cudnn.h not found at $expectedInstallLocation\include\cudnn.h"
exit 1
}
}
function Install-NvTools() {
$nvToolsLocalPath = "C:\Program Files\NVIDIA Corporation\NvToolsExt"
# Check if we actually need to do the install
if (Test-Path -Path "$nvToolsLocalPath" -PathType Container) {
Write-Output "Existing nvtools installation already found, continuing..."
return
}
$nvToolsUrl = "https://ossci-windows.s3.amazonaws.com/NvToolsExt.7z"
$tmpToolsDl = New-TemporaryFile
Write-Output "Downloading NvTools, $nvToolsUrl"
Invoke-WebRequest -Uri "$nvToolsUrl" -OutFile "$tmpToolsDl"
$tmpExtractedNvTools = New-TemporaryDirectory
7z x "$tmpToolsDl" -o"$tmpExtractedNvTools"
Write-Output "Copying NvTools, '$tmpExtractedNvTools' -> '$nvToolsLocalPath'"
New-Item -Path "$nvToolsLocalPath "-ItemType "directory" -Force
Copy-Item -Recurse -Path "$tmpExtractedNvTools\*" -Destination "$nvToolsLocalPath"
}
Install-CudaToolkit
Install-Cudnn
Install-NvTools
# Clear out temp files
Remove-Item -Path "$env:TEMP\*" -Recurse -Force -ErrorAction SilentlyContinue