Skip to content

Commit e13f4de

Browse files
committed
Corrected bug in GPU memory allocations causing effective memory leak with repeated modelling calls.
1 parent 7b67d10 commit e13f4de

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

lyceanem/electromagnetics/empropagation.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2208,6 +2208,8 @@ def EMGPUFreqDomain(
22082208
"""
22092209
# ctx = cuda.current_context()
22102210
# ctx.reset()
2211+
#clear GPU memory
2212+
cuda.current_context().memory_manager.deallocations.clear()
22112213
free_mem, total_mem = cuda.current_context().get_memory_info()
22122214
max_mem = np.ceil(free_mem).astype(np.int64)
22132215
ray_num = full_index.shape[0]

lyceanem/raycasting/rayfunctions.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2746,6 +2746,8 @@ def workchunkingv2(
27462746
sources.shape[0] * (scattering_points.shape[0] * sinks.shape[0] * (max_scatter))
27472747
)
27482748
# print("Total of {:3.1f} rays required".format(ray_estimate))
2749+
# Clear GPU memory for simulation
2750+
cuda.current_context().memory_manager.deallocations.clear()
27492751
# establish memory limits
27502752
free_mem, total_mem = cuda.current_context().get_memory_info()
27512753
max_mem = np.ceil(free_mem * 0.8).astype(np.int64)
@@ -2770,6 +2772,7 @@ def workchunkingv2(
27702772
)
27712773
if io_indexing.shape[0] >= ray_limit:
27722774
# need to split the array and process seperatly
2775+
27732776
sub_io = np.array_split(
27742777
io_indexing, np.ceil(io_indexing.shape[0] / ray_limit).astype(int)
27752778
)

0 commit comments

Comments
 (0)