Fix for systems without NVSMI

This commit is contained in:
iperov 2019-01-13 16:38:17 +04:00
parent 4625bcec1c
commit 12383570e8
3 changed files with 60 additions and 58 deletions

View file

@ -64,10 +64,12 @@ class ExtractSubprocessor(SubprocessorBase):
if (type == 'rects' or type == 'landmarks'):
if multi_gpu:
devices = nnlib.device.getDevicesWithAtLeastTotalMemoryGB(2)
else:
if not multi_gpu or len(devices) == 0:
devices = [nnlib.device.getBestDeviceIdx()]
if devices[0] == -1:
devices = []
if len(devices) == 0 or devices[0] == -1:
devices = [0]
devices = [ (idx, nnlib.device.getDeviceName(idx), nnlib.device.getDeviceVRAMTotalGb(idx) ) for idx in devices]
@ -86,9 +88,7 @@ class ExtractSubprocessor(SubprocessorBase):
'detector': self.detector}
if not self.cpu_only:
devices = self.get_devices_for_type(self.type, self.multi_gpu)
if len(devices) != 0:
for (device_idx, device_name, device_total_vram_gb) in devices:
for (device_idx, device_name, device_total_vram_gb) in self.get_devices_for_type(self.type, self.multi_gpu):
num_processes = 1
if not self.manual and self.type == 'rects' and self.detector == 'mt':
num_processes = int ( max (1, device_total_vram_gb / 2) )
@ -100,9 +100,7 @@ class ExtractSubprocessor(SubprocessorBase):
client_dict['device_type'] = 'GPU'
yield client_dict['device_name'], {}, client_dict
return
print ("No capable GPU's found, falling back to CPU mode.")
else:
num_processes = 1
if not self.manual and self.type == 'rects' and self.detector == 'mt':
num_processes = int ( max (1, multiprocessing.cpu_count() / 2 ) )

View file

@ -24,7 +24,7 @@ class devicelib:
**in_options):
self.use_fp16 = use_fp16
if cpu_only or not devicelib.hasNVML():
if cpu_only:
self.cpu_only = True
else:
self.force_best_gpu_idx = force_best_gpu_idx
@ -34,6 +34,13 @@ class devicelib:
self.allow_growth = allow_growth
self.gpu_idxs = []
if not devicelib.hasNVML():
self.gpu_idxs = [0]
self.gpu_total_vram_gb = 2
self.gpu_names += ['Generic GeForce GPU']
self.gpu_compute_caps += [ 50 ]
else:
if force_gpu_idxs is not None:
for idx in force_gpu_idxs.split(','):
idx = int(idx)
@ -215,7 +222,7 @@ class devicelib:
@staticmethod
def getDeviceName (idx):
result = ''
result = 'Generic GeForce GPU'
try:
nvmlInit()
if idx < nvmlDeviceGetCount():

View file

@ -129,9 +129,6 @@ NLayerDiscriminator = nnlib.NLayerDiscriminator
if nnlib.tf is not None:
return nnlib.code_import_tf
if not nnlib.device.hasNVML():
print ("nvml.dll not found. Reinstall Geforce video drivers.")
if 'TF_SUPPRESS_STD' in os.environ.keys() and os.environ['TF_SUPPRESS_STD'] == '1':
suppressor = std_utils.suppress_stdout_stderr().__enter__()
else: