MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / memory

Method memory

tensorpack/utils/nvml.py:92–113  ·  view source on GitHub ↗

Memory information in bytes Example: >>> print(ctx.device(0).memory()) {'total': 4238016512L, 'used': 434831360L, 'free': 3803185152L} Returns: total/used/free memory in bytes

(self)

Source from the content-addressed store, hash-verified

90 self.hnd = hnd
91
92 def memory(self):
93 """Memory information in bytes
94
95 Example:
96
97 >>> print(ctx.device(0).memory())
98 {'total': 4238016512L, 'used': 434831360L, 'free': 3803185152L}
99
100 Returns:
101 total/used/free memory in bytes
102 """
103 class GpuMemoryInfo(Structure):
104 _fields_ = [
105 ('total', c_ulonglong),
106 ('free', c_ulonglong),
107 ('used', c_ulonglong),
108 ]
109
110 c_memory = GpuMemoryInfo()
111 _check_return(_NVML.get_function(
112 "nvmlDeviceGetMemoryInfo")(self.hnd, byref(c_memory)))
113 return {'total': c_memory.total, 'free': c_memory.free, 'used': c_memory.used}
114
115 def utilization(self):
116 """Percent of time over the past second was utilized.

Callers

nothing calls this directly

Calls 3

GpuMemoryInfoClass · 0.85
_check_returnFunction · 0.85
get_functionMethod · 0.80

Tested by

no test coverage detected