Skip to content

Commit 617aac3

Browse files
authored
Add GPU memory guard to reproject dask+cupy path (#1131)
* Add sweep-performance design spec Parallel subagent triage + ralph-loop workflow for auditing all xrspatial modules for performance bottlenecks, OOM risk under 30TB dask workloads, and backend-specific anti-patterns. * Add sweep-performance implementation plan 7 tasks covering command scaffold, module scoring, parallel subagent dispatch, report merging, ralph-loop generation, and smoke tests. * Add sweep-performance slash command * Add GPU memory guard to reproject _reproject_dask_cupy (#1130)
1 parent e792422 commit 617aac3

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

xrspatial/reproject/__init__.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,19 @@ def _reproject_dask_cupy(
999999
src_res_x = (src_right - src_left) / src_w
10001000
src_res_y = (src_top - src_bottom) / src_h
10011001

1002+
# Memory guard: the full output is allocated on GPU.
1003+
estimated = out_shape[0] * out_shape[1] * 8 # float64
1004+
try:
1005+
free_gpu, _total = cp.cuda.Device().mem_info
1006+
if estimated > 0.8 * free_gpu:
1007+
raise MemoryError(
1008+
f"_reproject_dask_cupy needs ~{estimated / 1e9:.1f} GB on GPU "
1009+
f"for the full output but only ~{free_gpu / 1e9:.1f} GB free. "
1010+
f"Reduce output resolution or use the dask+numpy path."
1011+
)
1012+
except (AttributeError, RuntimeError):
1013+
pass # no device info available
1014+
10021015
result = cp.full(out_shape, nodata, dtype=cp.float64)
10031016

10041017
row_offset = 0

0 commit comments

Comments
 (0)