Skip to content

Commit 39dbffc

Browse files
committed
update get_memory_usage + switch to py3nvml library
1 parent aa393ec commit 39dbffc

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

nvdocker/nvdocker.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from subprocess import check_output
44
import re
55
import docker
6-
from pynvml import *
6+
from py3nvml.py3nvml import *
77

88
class NVDockerClient:
99

@@ -180,7 +180,12 @@ def gpu_memory_usage(id):
180180
if id not in gpus.keys():
181181
return None
182182
gpu_handle = gpus[id]["gpu_handle"]
183-
return nvmlDeviceGetMemoryInfo(gpu_handle)
183+
gpu_memory_data = nvmlDeviceGetMemoryInfo(gpu_handle)
184+
rv = {}
185+
#returns in megabytes
186+
rv["used"] = gpu_memory_data.used/1e6
187+
rv["free"] = gpu_memory_data.free/1e6
188+
return rv
184189

185190
@staticmethod
186191
def least_used_gpu():

0 commit comments

Comments
 (0)