Sygil-Dev / stable-diffusion

GNU Affero General Public License v3.0
1.72k stars 148 forks source link

Specifying gpu results in a crash when generating image #154

Closed oc013 closed 2 years ago

oc013 commented 2 years ago

Started webui.py with arguments --gpu 2 and after clicking generate received this message

Expected all tensors to be on the same device, but found at least two devices, cuda:2 and cuda:0! (when checking argument for argument index in method wrapper__index_select)

I found #114 with a similar error message. This is happening with default settings, just putting in a prompt, so gfpgan and esrgan are off.

ainub commented 2 years ago

Make sure you have the latest version and the correct facexlib installed. To be on the safe side, recreate the conda environment to pull the lib from this git.

hlky commented 2 years ago

Yes thanks @ainub for that gfpgan related fix, I'll put a note about this on the readme

@oc013 If gfpgan and esrgan are off it shouldn't be the same issue, try --gpu 2 --extra-models-gpu --esrgan-gpu 2 --gfpgan-gpu 2 though please it could be something to do with how the options are set, I only have 1 graphics card so it's difficult to test this properly on my end.

oc013 commented 2 years ago

I am updated to latest

If there are further updates for facexlib does conda not cover it?

sd  |   Attempting uninstall: facexlib
sd  |     Found existing installation: facexlib 0.2.4
sd  |     Uninstalling facexlib-0.2.4:
sd  |       Successfully uninstalled facexlib-0.2.4
sd  |   Running setup.py develop for facexlib

This is happening with default settings, just putting in a prompt, so gfpgan and esrgan are off.

hlky commented 2 years ago

Ok so can you try --gpu 2 --extra-models-gpu --esrgan-gpu 2 --gfpgan-gpu 2

oc013 commented 2 years ago

Same error, and I tried with gfpgan and esrgan enabled with the same effect

sd  |  Expected all tensors to be on the same device, but found at least two devices, cuda:2 and cuda:0! (when checking argument for argument index in method wrapper__index_select)
oc013 commented 2 years ago

It looks like the gpu param only works with --optimized flag, model.to(device) is only called when that is set

oc013 commented 2 years ago

Does that mean it's fixed?