def __init__(self, _limit_mem, _unit_sec=10e-3, _pid=utils_.getpid(), _gpu_id=0, _is_print=True): """ Unit: MiB Usage: @LimitGPUMemoryDecorator(_limit_mem=1024) def test(): a = torch.zeros([10, 3, 1080, 1920], device='cuda:0') b = torch.zeros([10, 3, 1080, 1920], device='cuda:0') c = a + b d = 2 * c + b """ GPUMemory.__init__(self, _pid=_pid, _gpu_id=_gpu_id) multithread_.BaseThread.__init__(self) threading.Thread.__init__(self) self.limit_mem = _limit_mem self.unit_sec = _unit_sec self.pid = _pid self.gpu_id = _gpu_id self.is_print = _is_print self.mem_curr = 0.0 self.is_lock = None self.is_terminate = None self._lock() self._unset_terminate() self.start()
def __init__(self, _pid=utils_.getpid(), _gpu_id=0): """ Unit: MiB """ self.pid = _pid self.gpu_id = _gpu_id self._renew()
def __init__(self, _limit_mem, _unit_sec=10e-3, _pid=utils_.getpid(), _gpu_id=0, _is_print=True): """ Unit: MiB Usage: LimitGPUMemory(_limit_mem=1024).start() # 1024 MiB """ GPUMemory.__init__(self, _pid=_pid, _gpu_id=_gpu_id) multithread_.BaseThread.__init__(self) threading.Thread.__init__(self) self.daemon = True self.limit_mem = _limit_mem self.unit_sec = _unit_sec self.pid = _pid self.gpu_id = _gpu_id self.is_print = _is_print self.mem_curr = 0.0 self.is_lock = None self.is_terminate = None self._lock() self._unset_terminate()
def __init__(self, _pid=utils_.getpid(), _gpu_id=0, _warmup=0): rsc_.GPUMemory.__init__(self, _pid=_pid, _gpu_id=_gpu_id) self.warmup = _warmup self.cnt_call = 0 self.mem_list = [] self.mem_len = 0 self.mem_sum = 0.0 self.mem_avg = 0.0 self.mem_max = 0.0
def __init__(self, _pid=utils_.getpid(), _gpu_id=0): rsc_.GPUMemory.__init__(self, _pid=_pid, _gpu_id=_gpu_id) DEBUG.__init__(self) self.mem_total = self.get_mem_gpu_total() self.mem_mb_prev = self.get_mem_gpu_proc() self.mem_mb_curr = 0.0 self.mem_desc = None self.mem_variation = 0.0 self.mem_percent_curr = 100 * (self.mem_mb_prev / self.mem_total)
def __init__(self, _pid=utils_.getpid()): rsc_.MainMemory.__init__(self, _pid=_pid) DEBUG.__init__(self) self.proc = utils_.getproc(_pid=_pid) self.mem_mb_prev = self.get_mem_main_proc() self.mem_mb_curr = 0.0 self.mem_total = self.get_mem_main_total() self.mem_desc = None self.mem_variation = 0.0 self.mem_percent_curr = 100 * (self.mem_mb_prev / self.mem_total)
def __init__(self, _pid=utils_.getpid(), _warmup=0): rsc_.MainMemory.__init__(self, _pid=_pid) self.warmup = _warmup self.cnt_call = 0 self.mem_list = [] self.mem_len = 0 self.mem_sum = 0.0 self.mem_avg = 0.0 self.mem_max = 0.0 self.proc = utils_.getproc(_pid=_pid)
def get_info_proc(self, _pid=utils_.getpid(), _gpu_info=None): if _gpu_info is None: raise ValueError('The argument, _gpu_info, should be assigned.') self.pid = _pid gpu_procs = _gpu_info['gpu_procs'] gpu_proc_index = self._get_gpu_procs_index(_gpu_procs=gpu_procs) if gpu_proc_index is None: gpu_proc = { 'username': None, 'command': None, 'gpu_memory_usage': 0, 'pid': self.pid, 'is_proc': False } else: gpu_proc = gpu_procs[gpu_proc_index] gpu_proc['is_proc'] = True return gpu_proc
def __init__(self, _limit_sec: int, _pid: int = utils_.getpid()) -> None: """ Usage: Arguments: _lmit_sec: only support second. class Test(rsc_.LimitRunTime): def __init__(self, _limit_sec, _pid=utils_.getpid()): super(Test, self).__init__(_limit_sec, _pid=_pid) self.pid = _pid def run(self): cnt = 0 while True: print('[{}]: {}'.format(cnt, self.pid)) cnt += 1 """ self.limit_sec = int(math.floor(_limit_sec)) self.pid = _pid soft, hard = resource.getrlimit(resource.RLIMIT_CPU) resource.setrlimit(resource.RLIMIT_CPU, (_limit_sec, hard)) signal.signal(signal.SIGXCPU, self._time_exceeded)
def __init__(self, _pid=utils_.getpid()): """ Unit: MiB """ self.pid = _pid self.proc = utils_.getproc(_pid=self.pid)
def __init__(self, _pid: int = utils_.getpid(), _gpu_id: int = 0) -> None: self.prof_time = TimeProfiler() self.prof_mem_main = MainMemoryProfiler(_pid=_pid) self.prof_mem_gpu = GPUMemoryProfiler(_pid=_pid, _gpu_id=_gpu_id)