你已经派生过 gprMax
镜像自地址
https://gitee.com/sunhf/gprMax.git
已同步 2025-08-07 23:14:03 +08:00
Manual gc
这个提交包含在:
@@ -82,10 +82,14 @@ class Context:
|
||||
if not config.sim_config.args.geometry_only:
|
||||
solver = create_solver(G)
|
||||
model.solve(solver)
|
||||
del solver, model
|
||||
|
||||
if not config.sim_config.args.geometry_fixed:
|
||||
del solver, model, G
|
||||
gc.collect()
|
||||
# Manual garbage collection required to stop memory leak on GPUs
|
||||
# when using pycuda
|
||||
del G
|
||||
|
||||
gc.collect()
|
||||
|
||||
self.tsimend = timer()
|
||||
self.print_sim_time_taken()
|
||||
@@ -147,8 +151,11 @@ class MPIContext(Context):
|
||||
if not config.sim_config.args.geometry_only:
|
||||
solver = create_solver(G)
|
||||
model.solve(solver)
|
||||
del solver, model
|
||||
|
||||
del solver, model, G
|
||||
# Manual garbage collection required to stop memory leak on GPUs when
|
||||
# using pycuda
|
||||
del G
|
||||
gc.collect()
|
||||
|
||||
def run(self):
|
||||
|
@@ -17,6 +17,7 @@
|
||||
# along with gprMax. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import logging
|
||||
import subprocess
|
||||
from importlib import import_module
|
||||
|
||||
import numpy as np
|
||||
@@ -753,8 +754,11 @@ class CUDAUpdates:
|
||||
Memory (RAM) used on GPU.
|
||||
"""
|
||||
if iteration == self.grid.iterations - 1:
|
||||
# Total minus free memory in current context
|
||||
return self.drv.mem_get_info()[1] - self.drv.mem_get_info()[0]
|
||||
mem_used = subprocess.check_output(["nvidia-smi", "--query-gpu=memory.used"],
|
||||
shell=False, stderr=subprocess.STDOUT)
|
||||
return mem_used
|
||||
# # Total minus free memory in current context
|
||||
# return self.drv.mem_get_info()[1] - self.drv.mem_get_info()[0]
|
||||
|
||||
def calculate_solve_time(self):
|
||||
"""Calculates solving time for model."""
|
||||
|
在新工单中引用
屏蔽一个用户