Skip to content
This repository has been archived by the owner on Sep 7, 2022. It is now read-only.

Tensor needs to be moved from one gpu to the other. #114

Closed
ainub opened this issue Aug 29, 2022 · 5 comments
Closed

Tensor needs to be moved from one gpu to the other. #114

ainub opened this issue Aug 29, 2022 · 5 comments

Comments

@ainub
Copy link

ainub commented Aug 29, 2022

Great feature to be able to run esrgan and gfpgan on another GPU, however, tensor needs to be moved:
Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cuda:1! (when checking argument for argument weight in method wrapper__cudnn_convolution)

@hlky
Copy link

hlky commented Aug 30, 2022

When is this happening? Are you using gfpgan/esrgan as an option on generation, or in their standalone tabs?

gpu 1 is the card you're using for gfpgan/esrgan and gpu 0 is the card for the main model, correct?

Have you tried explicitly setting --gpu option as well as the other options? there might be something messed up with how the selected gpus are applied

@ainub
Copy link
Author

ainub commented Aug 30, 2022

The problem seems to be only with GFPGAN. It throws the error in both option on generation as well as in standalone tab mode.

esrgan is working correctly.

Your assumption is correct: gpu 1 for gfpgan/esrgan and gpu 0 for main model. I have now tried both with explicit gpu set and without:
python scripts/webui.py --optimized-turbo --gpu 0 --extra-models-gpu --esrgan-gpu 1 --gfpgan-gpu 1
python scripts/webui.py --optimized-turbo --extra-models-gpu --esrgan-gpu 1 --gfpgan-gpu 1

I tried the non-optimized variant as well, same result (esrgan works, gfpgan doesn't)
python scripts/webui.py --gpu 0 --extra-models-gpu --esrgan-gpu 1 --gfpgan-gpu 1

!!Runtime error (txt2img)!! Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cuda:1! (when checking argument for argument weight in method wrapper__cudnn_convolution) exiting...calling os._exit(0)

Thank you for sharing your interface, it helps a lot.

@ainub
Copy link
Author

ainub commented Aug 30, 2022

Traceback led me to a facexlib problem.
Someone else also mentioned it here: https://github.com/AbdBarho/stable-diffusion-webui-docker/issues/4#issuecomment-1231927656

I guess the only way would be to manually patch facexlib or move GFPGAN to cpu only in case you don't want it on GPU.

@ainub
Copy link
Author

ainub commented Aug 30, 2022

Ok, fixed this way:

conda activate ldm
pip uninstall facexlib
git clone https://github.com/xinntao/facexlib
cd facexlib
git pull origin pull/19/head
python setup.py install
cd ..
python scripts/webui.py --optimized-turbo --gpu 0 --extra-models-gpu --esrgan-gpu 1 --gfpgan-gpu 1

And everything is working as intended.

@hlky
Copy link

hlky commented Aug 30, 2022

I've forked, merged that pull request into the fork, and updated the environment.yaml so should be fixed for all now, thanks!

@hlky hlky closed this as completed Aug 30, 2022
mabrowning pushed a commit to mabrowning/hlky-stable-diffusion that referenced this issue Sep 6, 2022
Replace numerical size inputs with dropdowns
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants