mirror of
https://github.com/easydiffusion/easydiffusion.git
synced 2025-04-17 16:08:34 +02:00
More fixes to devices changing names.
This commit is contained in:
parent
fcdb086daf
commit
53cdeeff03
@ -351,23 +351,14 @@ def do_mk_img(req: Request):
|
||||
thread_data.ckpt_file = req.use_stable_diffusion_model
|
||||
needs_model_reload = True
|
||||
|
||||
if req.use_cpu:
|
||||
if thread_data.device != 'cpu':
|
||||
thread_data.device = 'cpu'
|
||||
if thread_data.model_is_half:
|
||||
load_model_ckpt()
|
||||
needs_model_reload = False
|
||||
if thread_data.has_valid_gpu:
|
||||
if (thread_data.precision == 'autocast' and (req.use_full_precision or not thread_data.model_is_half)) or \
|
||||
(thread_data.precision == 'full' and not req.use_full_precision and not thread_data.force_full_precision):
|
||||
thread_data.precision = 'full' if req.use_full_precision else 'autocast'
|
||||
load_model_ckpt()
|
||||
load_model_gfpgan()
|
||||
load_model_real_esrgan()
|
||||
else:
|
||||
if thread_data.has_valid_gpu:
|
||||
if (thread_data.precision == 'autocast' and (req.use_full_precision or not thread_data.model_is_half)) or \
|
||||
(thread_data.precision == 'full' and not req.use_full_precision and not thread_data.force_full_precision):
|
||||
thread_data.precision = 'full' if req.use_full_precision else 'autocast'
|
||||
load_model_ckpt()
|
||||
load_model_gfpgan()
|
||||
load_model_real_esrgan()
|
||||
needs_model_reload = False
|
||||
needs_model_reload = False
|
||||
|
||||
if needs_model_reload:
|
||||
load_model_ckpt()
|
||||
@ -593,7 +584,8 @@ def do_mk_img(req: Request):
|
||||
move_fs_to_cpu()
|
||||
gc()
|
||||
del x_samples, x_samples_ddim, x_sample
|
||||
print(f'memory_final = {round(torch.cuda.memory_allocated(thread_data.device) / 1e6, 2)}Mo')
|
||||
if thread_data.device != 'cpu':
|
||||
print(f'memory_final = {round(torch.cuda.memory_allocated(thread_data.device) / 1e6, 2)}Mo')
|
||||
|
||||
print('Task completed')
|
||||
|
||||
|
@ -346,21 +346,21 @@ async def check_status(): # Task to Validate user config shortly after startup.
|
||||
# Issues found, try to fix and warn the user.
|
||||
device_count = 0
|
||||
for i in range(10): # Wait for devices to register and/or change names.
|
||||
await asyncio.sleep(3)
|
||||
new_count = task_manager.is_alive()
|
||||
if device_count == new_count: break;
|
||||
device_count = new_count
|
||||
await asyncio.sleep(3)
|
||||
|
||||
if 'render_devices' in config and task_manager.is_alive() <= 0: # No running devices, probably invalid user config. Try to apply defaults.
|
||||
task_manager.start_render_thread('auto') # Detect best device for renders
|
||||
task_manager.start_render_thread('cpu') # Allow CPU to be used for renders
|
||||
await asyncio.sleep(10) # delay message after thread start.
|
||||
await asyncio.sleep(3) # delay message after thread start.
|
||||
|
||||
display_warning = False
|
||||
if not 'render_devices' in config and task_manager.is_alive(0) <= 0: # No config set, is on auto mode and without cuda:0
|
||||
task_manager.start_render_thread('cuda') # An other cuda device is better and cuda:0 is missing, start it...
|
||||
display_warning = True # And warn user to update settings...
|
||||
await asyncio.sleep(10) # delay message after thread start.
|
||||
await asyncio.sleep(3) # delay message after thread start.
|
||||
|
||||
if display_warning or task_manager.is_alive(0) <= 0:
|
||||
print('WARNING: GFPGANer only works on CPU or GPU:0, use CUDA_VISIBLE_DEVICES if GFPGANer is needed on a specific GPU.')
|
||||
@ -378,8 +378,7 @@ if 'render_devices' in config: # Start a new thread for each device.
|
||||
for device in config['render_devices']:
|
||||
task_manager.start_render_thread(device)
|
||||
else:
|
||||
# Select best device GPU device using free memory if more than one device.
|
||||
#task_manager.start_render_thread('cuda') # Starts silently on cuda:0
|
||||
# Select best GPU device using free memory, if more than one device.
|
||||
task_manager.start_render_thread('auto') # Detect best device for renders
|
||||
task_manager.start_render_thread('cpu') # Allow CPU to be used for renders
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user