MCPcopy Index your code
hub / github.com/PaddlePaddle/PaddleDetection / get_current_memory_mb

Function get_current_memory_mb

deploy/python/utils.py:323–346  ·  view source on GitHub ↗

It is used to Obtain the memory usage of the CPU and GPU during the running of the program. And this function Current program is time-consuming.

()

Source from the content-addressed store, hash-verified

321
322
323def get_current_memory_mb():
324 """
325 It is used to Obtain the memory usage of the CPU and GPU during the running of the program.
326 And this function Current program is time-consuming.
327 """
328 import pynvml
329 import psutil
330 import GPUtil
331 gpu_id = int(os.environ.get('CUDA_VISIBLE_DEVICES', 0))
332
333 pid = os.getpid()
334 p = psutil.Process(pid)
335 info = p.memory_full_info()
336 cpu_mem = info.uss / 1024. / 1024.
337 gpu_mem = 0
338 gpu_percent = 0
339 gpus = GPUtil.getGPUs()
340 if gpu_id is not None and len(gpus) > 0:
341 gpu_percent = gpus[gpu_id].load
342 pynvml.nvmlInit()
343 handle = pynvml.nvmlDeviceGetHandleByIndex(0)
344 meminfo = pynvml.nvmlDeviceGetMemoryInfo(handle)
345 gpu_mem = meminfo.used / 1024. / 1024.
346 return round(cpu_mem, 4), round(gpu_mem, 4), round(gpu_percent, 4)
347
348
349def multiclass_nms(bboxs, num_classes, match_threshold=0.6, match_metric='iou'):

Callers 11

predict_imageMethod · 0.90
topdown_unite_predictFunction · 0.90
predict_image_sliceMethod · 0.90
predict_imageMethod · 0.90
predict_imageMethod · 0.90
predict_imageMethod · 0.90
predict_imageMethod · 0.90
predict_imageMethod · 0.90
mainFunction · 0.90
predict_skeletonMethod · 0.90

Calls 1

getMethod · 0.45

Tested by

no test coverage detected