mirror of
https://github.com/easydiffusion/easydiffusion.git
synced 2024-11-23 16:53:35 +01:00
Process GPU tasks on CPU when there are no cuda devices at all.
This commit is contained in:
parent
d4a348a2b2
commit
012243a880
@ -157,7 +157,7 @@ class TaskCache():
|
|||||||
finally:
|
finally:
|
||||||
self._lock.release()
|
self._lock.release()
|
||||||
|
|
||||||
manager_lock = threading.Lock()
|
manager_lock = threading.RLock()
|
||||||
render_threads = []
|
render_threads = []
|
||||||
current_state = ServerStates.Init
|
current_state = ServerStates.Init
|
||||||
current_state_error:Exception = None
|
current_state_error:Exception = None
|
||||||
@ -212,13 +212,26 @@ def thread_render(device):
|
|||||||
continue
|
continue
|
||||||
try: # Select a render task.
|
try: # Select a render task.
|
||||||
for queued_task in tasks_queue:
|
for queued_task in tasks_queue:
|
||||||
if queued_task.request.use_cpu and runtime.thread_data.device != 'cpu':
|
cpu_alive = is_alive('cpu')
|
||||||
continue # Cuda Tasks
|
if queued_task.request.use_face_correction: #TODO Remove when fixed - A bug with GFPGANer and facexlib needs to be fixed before use on other devices.
|
||||||
if not queued_task.request.use_cpu and runtime.thread_data.device == 'cpu':
|
# Allows GFPGANer on cuda:0 and use cpu only when cuda:0 is not available.
|
||||||
continue # CPU Tasks
|
first_device_alive = True if is_alive(0) >= 1 else False
|
||||||
if queued_task.request.use_face_correction and not runtime.is_first_cuda_device(runtime.thread_data.device):
|
if cpu_alive <= 0 and not first_device_alive:
|
||||||
if not runtime.thread_data.device == 'cpu' and is_alive(0) > 0: # Allows GFPGANer on cuda:0 and use cpu only when cuda:0 is not available.
|
queued_task.request.use_face_correction = False
|
||||||
continue #TODO Remove when fixed - A bug with GFPGANer and facexlib needs to be fixed before use on other devices.
|
print('cuda:0 and cpu are not available with the current config. Removed GFPGANer filter to run task.')
|
||||||
|
continue
|
||||||
|
if not queued_task.request.use_cpu:
|
||||||
|
if first_device_alive:
|
||||||
|
if not runtime.is_first_cuda_device(runtime.thread_data.device):
|
||||||
|
continue # Wait for cuda:0
|
||||||
|
elif cpu_alive > 0:
|
||||||
|
print('cuda:0 is not available with the current config. Forcing task requiring GFPGANer to cpu.')
|
||||||
|
queued_task.request.use_cpu = True
|
||||||
|
continue
|
||||||
|
if queued_task.request.use_cpu and runtime.thread_data.device != 'cpu' and cpu_alive > 0:
|
||||||
|
continue # CPU Tasks, Skip GPU device
|
||||||
|
if not queued_task.request.use_cpu and runtime.thread_data.device == 'cpu' and is_alive() > 1: # cpu is alive, so need more than one.
|
||||||
|
continue # GPU Tasks, don't run on CPU unless there is nothing else.
|
||||||
task = queued_task
|
task = queued_task
|
||||||
break
|
break
|
||||||
if task is not None:
|
if task is not None:
|
||||||
|
Loading…
Reference in New Issue
Block a user