-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNVIDIA_MakeDL_Tools.bat
More file actions
337 lines (288 loc) · 14.6 KB
/
NVIDIA_MakeDL_Tools.bat
File metadata and controls
337 lines (288 loc) · 14.6 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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
@echo off
:: --- Self-elevate to Admin (UAC) ---
>nul 2>&1 net session || (powershell -NoProfile -ExecutionPolicy Bypass -Command "Start-Process -FilePath '%~f0' -Verb RunAs" & exit /b)
setlocal enabledelayedexpansion
echo.
echo ==========================================================================================
echo STARTING GPU SETUP...
echo ==========================================================================================
echo.
echo.
echo ==========================================================================================
echo Checking for NVIDIA GPU and driver information...
echo ==========================================================================================
echo.
for /f "skip=1 delims=" %%i in ('nvidia-smi --query-gpu=name --format=csv') do set "gpu_name=%%i"
for /f "skip=1 delims=" %%i in ('nvidia-smi --query-gpu=driver_version --format=csv') do set "driver_version=%%i"
for /f "skip=1 delims=" %%i in ('nvidia-smi --query-gpu=compute_cap --format=csv') do set "compute_cap=%%i"
echo.
echo ==========================================================================================
echo GPU Name : %gpu_name%
echo Driver Version : %driver_version%
echo Compute Capability : %compute_cap%
echo ==========================================================================================
echo.
set "min_comp=7.5"
if "%compute_cap%" LSS "%min_comp%" (
echo.
echo ==========================================================================================
echo [ERROR] SORRY YOUR DEVICE IS NOT CUDA COMPATIBLE...
echo ==========================================================================================
echo.
exit /b
) else (
echo.
echo ==========================================================================================
echo [INFO] Your device is CUDA compatible.
echo ==========================================================================================
echo.
)
set "gpu_info=%gpu_name%|%driver_version%|%compute_cap%"
echo.
echo ==========================================================================================
echo Checking latest NVIDIA Studio Driver version online...
echo ==========================================================================================
echo.
for /f "usebackq tokens=*" %%i in (`powershell -NoProfile -Command ^
"$url='https://www.nvidia.com/Download/processFind.aspx?psid=107&pfid=877&osid=135&lid=1&dtcid=1';" ^
"$html=(Invoke-WebRequest -Uri $url).Content;" ^
"$match=[regex]::Matches($html, '<td class=\"gridItem\">(\d+\.\d+)</td>');" ^
"($match | ForEach-Object { $_.Groups[1].Value } | Sort-Object {[decimal]$_} -Descending | Select-Object -First 1)"`) do (
set "latest_version=%%i"
)
:: clean both values: keep only digits and dot
set "driver_version=!driver_version: =!"
set "latest_version=!latest_version: =!"
for /f "tokens=1 delims=" %%A in ("!latest_version!") do set "latest_version=%%~A"
for /f "tokens=1 delims=" %%A in ("!driver_version!") do set "driver_version=%%~A"
for /f "delims=0123456789." %%A in ("!driver_version!") do set "driver_version=!driver_version:%%A=!"
for /f "delims=0123456789." %%A in ("!latest_version!") do set "latest_version=!latest_version:%%A=!"
echo.
echo ==========================================================================================
echo Latest Available Driver Version : !latest_version!
echo Installed Driver Version : !driver_version!
echo ==========================================================================================
echo.
echo.
echo ==========================================================================================
echo STARTING DRIVER INSTALLATION...
echo ==========================================================================================
echo.
if "%latest_version%" NEQ "%driver_version%" (
echo [INFO] Installed driver %driver_version% is older than latest %latest_version%.
echo.
if exist NVIDIA_Driver.exe (
echo.
echo ==========================================================================================
echo [INFO] Found existing NVIDIA_Driver.exe, running installer...
echo ==========================================================================================
start /wait NVIDIA_Driver.exe
echo Installer finished.
echo Path: %cd%\NVIDIA_Driver.exe
echo Exit code: !errorlevel!
echo ==========================================================================================
echo.
goto :cuda_start
) else (
echo [INFO] Downloading and installing latest driver...
echo.
set "dl_url=https://us.download.nvidia.com/Windows/%latest_version%/%latest_version%-desktop-win10-win11-64bit-international-dch-whql.exe"
echo Downloading from !dl_url!
curl -L -# -o NVIDIA_Driver.exe "!dl_url!"
echo Starting installer...
start /wait NVIDIA_Driver.exe
echo Exit code: !errorlevel!
)
) else (
echo ==========================================================================================
echo [INFO] Your driver is already up to date.
echo ==========================================================================================
echo.
)
:cuda_start
echo.
echo ==========================================================================================
echo STARTING CUDA INSTALLATION...
echo ==========================================================================================
echo.
where nvcc >nul 2>&1
if %errorlevel% neq 0 (
echo [INFO] CUDA not found on system.
set cuda_version=0.0
) else (
for /f "tokens=2 delims=," %%a in ('nvcc --version ^| findstr /i "release"') do (
for /f "tokens=2 delims= " %%b in ("%%a") do (
set "cuda_version=%%b"
)
)
)
echo.
echo ==========================================================================================
echo [INFO] Detected CUDA version: %cuda_version%
echo ==========================================================================================
echo.
set required_version=13.0
if "%cuda_version%"=="%required_version%" (
echo ==========================================================================================
echo [INFO] CUDA version %cuda_version% is already installed.
echo ==========================================================================================
goto :cudnn_start
)
for /f "tokens=1,2 delims=." %%x in ("%cuda_version%") do (
set major=%%x
set minor=%%y
)
if not defined major set major=0
if not defined minor set minor=0
if %major% gtr 13 (
echo ==========================================================================================
echo [INFO] CUDA version %cuda_version% is newer than 13.0. Skipping install.
echo ==========================================================================================
goto :cudnn_start
)
if %major%==13 if %minor% geq 0 (
echo ==========================================================================================
echo [INFO] CUDA version %cuda_version% is already >= 13.0.
echo ==========================================================================================
goto :cudnn_start
)
set installer=cuda_13.0.0_windows.exe
set url=https://developer.download.nvidia.com/compute/cuda/13.0.0/local_installers/cuda_13.0.0_windows.exe
if exist "%installer%" (
echo ==========================================================================================
echo [INFO] Installer already exists: %installer%
echo ==========================================================================================
) else (
echo ==========================================================================================
echo [INFO] Downloading CUDA 13.0 installer...
echo ==========================================================================================
curl -L -o "%installer%" --progress-bar "%url%"
if %errorlevel% neq 0 (
echo ==========================================================================================
echo [ERROR] Failed to download installer.
echo ==========================================================================================
exit /b 1
)
)
echo ==========================================================================================
echo [INFO] Running CUDA installer...
echo ==========================================================================================
echo [ACTION] Approve UAC prompts if asked.
start /wait "" "%installer%"
echo ==========================================================================================
echo [INFO] CUDA 13.0 installation finished.
echo ==========================================================================================
echo.
if exist "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0" (
echo ==========================================================================================
echo [SUCCESS] CUDA 13.0 installation verified: Folder exists.
echo ==========================================================================================
echo.
) else (
echo ==========================================================================================
echo [ERROR] CUDA folder not found. Installation may have failed.
echo ==========================================================================================
)
REM Check if nvcc is accessible again
where nvcc >nul 2>&1
if %errorlevel%==0 (
nvcc --version
) else (
echo ==========================================================================================
echo [ERROR] nvcc not found in PATH.
echo ==========================================================================================
)
:cudnn_start
echo.
echo ==========================================================================================
echo STARTING cuDNN INSTALLATION...
echo ==========================================================================================
echo.
set cudnn_installer=cudnn_9.12.0_windows.exe
set cudnn_url=https://developer.download.nvidia.com/compute/cudnn/9.12.0/local_installers/cudnn_9.12.0_windows.exe
set cuda_root=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0
set cudnn_base=C:\Program Files\NVIDIA\cuDNN\v9.12
set cudnn_in_cuda=%cuda_root%\include\cudnn.h
if exist "%cudnn_base%" (
echo ==========================================================================================
echo [INFO] cuDNN base folder exists: %cudnn_base%
echo ==========================================================================================
if exist "%cudnn_in_cuda%" (
echo ==========================================================================================
echo [INFO] cuDNN header file exists in CUDA include directory:
echo %cudnn_in_cuda%
echo ==========================================================================================
goto :success
) else (
echo ==========================================================================================
echo [ERROR] cuDNN header file not found in CUDA include directory:
echo %cudnn_in_cuda%
echo Copying cuDNN to CUDA directories...
echo ==========================================================================================
goto :copy_part
)
)
REM === Step 1: Download cuDNN if not present ===
if exist "%cudnn_installer%" (
echo ==========================================================================================
echo [INFO] cuDNN installer already exists: %cudnn_installer%
echo ==========================================================================================
) else (
echo ==========================================================================================
echo [INFO] Downloading cuDNN installer...
echo ==========================================================================================
curl -L -o "%cudnn_installer%" --progress-bar "%cudnn_url%"
if %errorlevel% neq 0 (
echo ==========================================================================================
echo [ERROR] Failed to download cuDNN installer.
echo ==========================================================================================
exit /b 1
)
)
REM === Step 2: Run installer ===
echo ==========================================================================================
echo [INFO] Running cuDNN installer...
echo ==========================================================================================
start /wait "" "%cudnn_installer%"
echo ==========================================================================================
echo [INFO] cuDNN installation finished.
echo ==========================================================================================
echo.
REM === Step 3: Locate cuDNN installation path ===
if not exist "%cudnn_base%" (
echo ==========================================================================================
echo [ERROR] Could not find cuDNN installation folder:
echo %cudnn_base%
echo Please verify installation path manually.
echo ==========================================================================================
goto :eof
)
:copy_part
REM === Step 4: Copy cuDNN files into CUDA directories ===
echo ==========================================================================================
echo [INFO] Copying cuDNN files into CUDA directories...
echo ==========================================================================================
if exist "%cudnn_base%\bin" (
xcopy /Y /E "%cudnn_base%\bin\13.0\*" "%cuda_root%\bin\"
)
if exist "%cudnn_base%\include" (
xcopy /Y /E "%cudnn_base%\include\13.0\*" "%cuda_root%\include\"
)
if exist "%cudnn_base%\lib" (
xcopy /Y /E "%cudnn_base%\lib\13.0\x64\cudnn.lib*" "%cuda_root%\lib\x64\"
)
:success
echo.
echo ==========================================================================================
echo [SUCCESS] cuDNN setup completed and integrated with CUDA 13.0.
echo © Chandradithya_MakeFiles 2025
echo ==========================================================================================
echo.
echo.
echo ==========================================================================================
echo YOU CAN NOW USE YOUR NVIDIA GPU WITH CUDA AND cuDNN!
echo ==========================================================================================
echo.
:end
endlocal
pause