()
| 6 | |
| 7 | #Can't use pytorch to get the GPU names because the cuda malloc has to be set before the first import. |
| 8 | def get_gpu_names(): |
| 9 | if os.name == 'nt': |
| 10 | import ctypes |
| 11 | |
| 12 | # Define necessary C structures and types |
| 13 | class DISPLAY_DEVICEA(ctypes.Structure): |
| 14 | _fields_ = [ |
| 15 | ('cb', ctypes.c_ulong), |
| 16 | ('DeviceName', ctypes.c_char * 32), |
| 17 | ('DeviceString', ctypes.c_char * 128), |
| 18 | ('StateFlags', ctypes.c_ulong), |
| 19 | ('DeviceID', ctypes.c_char * 128), |
| 20 | ('DeviceKey', ctypes.c_char * 128) |
| 21 | ] |
| 22 | |
| 23 | # Load user32.dll |
| 24 | user32 = ctypes.windll.user32 |
| 25 | |
| 26 | # Call EnumDisplayDevicesA |
| 27 | def enum_display_devices(): |
| 28 | device_info = DISPLAY_DEVICEA() |
| 29 | device_info.cb = ctypes.sizeof(device_info) |
| 30 | device_index = 0 |
| 31 | gpu_names = set() |
| 32 | |
| 33 | while user32.EnumDisplayDevicesA(None, device_index, ctypes.byref(device_info), 0): |
| 34 | device_index += 1 |
| 35 | gpu_names.add(device_info.DeviceString.decode('utf-8')) |
| 36 | return gpu_names |
| 37 | return enum_display_devices() |
| 38 | else: |
| 39 | gpu_names = set() |
| 40 | out = subprocess.check_output(['nvidia-smi', '-L']) |
| 41 | for l in out.split(b'\n'): |
| 42 | if len(l) > 0: |
| 43 | gpu_names.add(l.decode('utf-8').split(' (UUID')[0]) |
| 44 | return gpu_names |
| 45 | |
| 46 | blacklist = {"GeForce GTX TITAN X", "GeForce GTX 980", "GeForce GTX 970", "GeForce GTX 960", "GeForce GTX 950", "GeForce 945M", |
| 47 | "GeForce 940M", "GeForce 930M", "GeForce 920M", "GeForce 910M", "GeForce GTX 750", "GeForce GTX 745", "Quadro K620", |
no test coverage detected