Skip to content

Commit 71856e2

Browse files
Fix CI disk space exhaustion during CUDA libtorch download
Add aggressive disk cleanup steps to prevent out-of-memory failures when downloading and extracting large PyTorch 2.10.0 CUDA binaries: - Linux: Remove .git dir and clear NuGet cache in initial cleanup (matching existing Windows behavior) - Both platforms: Delete CPU intermediate extraction dir and downloads before starting CUDA download - Both platforms: Delete CUDA intermediate extraction dir and downloads after CUDA build completes Only intermediate build directories are removed; the final packprep output used for publish artifacts is preserved. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent e9759cf commit 71856e2

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

azure-pipelines.yml

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,10 @@ jobs:
117117
vmImage: 'ubuntu-latest'
118118
container: UbuntuContainer
119119
steps:
120-
# Initial cleanup
120+
# Initial cleanup - free as much disk space as possible
121121
- script: |
122+
rm -rf .git
123+
dotnet nuget locals all --clear 2>/dev/null || true
122124
rm -rf bin/obj
123125
find . -name "*.pdb" -type f -delete
124126
find . -name "*.xml" -type f -delete
@@ -145,6 +147,15 @@ jobs:
145147
condition: eq('${{ parameters.BuildLibTorchPackages }}', true)
146148
displayName: Download libtorch native binaries and cleanup archives
147149
150+
# Free intermediate space before CUDA download
151+
- script: |
152+
rm -rf bin/obj/AnyCPU.$(BuildConfig)/libtorch-cpu
153+
rm -rf bin/downloads
154+
df -h
155+
condition: eq('${{ parameters.BuildLibTorchPackages }}', true)
156+
displayName: Free disk space before CUDA download
157+
continueOnError: true
158+
148159
# Build libtorch CUDA and clean immediately
149160
- script: |
150161
dotnet build -c $(BuildConfig) src/Redist/libtorch-cuda-12.8/libtorch-cuda-12.8.proj /p:UpdateSHA=true /p:SkipTests=true /p:TargetOS=linux /t:Build /p:IncludeLibTorchCudaPackages=true
@@ -154,6 +165,15 @@ jobs:
154165
condition: eq('${{ parameters.BuildLibTorchPackages }}', true)
155166
displayName: Download libtorch CUDA binaries and cleanup archives
156167
168+
# Free intermediate space after CUDA build
169+
- script: |
170+
rm -rf bin/obj/AnyCPU.$(BuildConfig)/libtorch-cuda-12.8
171+
rm -rf bin/downloads
172+
df -h
173+
condition: eq('${{ parameters.BuildLibTorchPackages }}', true)
174+
displayName: Free disk space after CUDA build
175+
continueOnError: true
176+
157177
- script: dotnet build -c $(BuildConfig) src/TorchSharp/TorchSharp.csproj /p:SkipCuda=true /p:SkipTests=true
158178
displayName: Build TorchSharp
159179

@@ -211,6 +231,15 @@ jobs:
211231
displayName: Download libtorch native binaries and cleanup
212232
condition: eq('${{ parameters.BuildLibTorchPackages }}', true)
213233
234+
# Free intermediate space before CUDA download
235+
- script: |
236+
rmdir /s /q bin\obj\AnyCPU.$(BuildConfig)\libtorch-cpu 2>nul
237+
rmdir /s /q bin\downloads 2>nul
238+
dir
239+
condition: eq('${{ parameters.BuildLibTorchPackages }}', true)
240+
displayName: Free disk space before CUDA download
241+
continueOnError: true
242+
214243
# Build libtorch CUDA and clean immediately
215244
- script: |
216245
dotnet build -c $(BuildConfig) src/Redist/libtorch-cuda-12.8/libtorch-cuda-12.8.proj /p:UpdateSHA=true /p:SkipTests=true /p:TargetOS=windows /t:Build /p:IncludeLibTorchCudaPackages=true
@@ -219,6 +248,14 @@ jobs:
219248
condition: eq('${{ parameters.BuildLibTorchPackages }}', true)
220249
displayName: Download libtorch CUDA binaries and cleanup
221250
251+
# Free intermediate space after CUDA build
252+
- script: |
253+
rmdir /s /q bin\obj\AnyCPU.$(BuildConfig)\libtorch-cuda-12.8 2>nul
254+
rmdir /s /q bin\downloads 2>nul
255+
condition: eq('${{ parameters.BuildLibTorchPackages }}', true)
256+
displayName: Free disk space after CUDA build
257+
continueOnError: true
258+
222259
- script: dotnet build -c $(BuildConfig) src/TorchSharp/TorchSharp.csproj /p:SkipCuda=true /p:SkipTests=true
223260
condition: eq('${{ parameters.BuildLibTorchPackages }}', true)
224261
displayName: Build TorchSharp

0 commit comments

Comments
 (0)