If you are using an Nvidia Graphic Card with lower vrams (4Gb-8Gb) and are trying to run Stable Diffusion locally in your pc via Automatic SD Webui then you have most probably faced one or both of these two problems, 1. black screen in output or 2. Runtime error : cuda out of memory. I am not gonna explain what Stable Diffusion is or how to install one and going straight to the point. If you want to install and run Stable diffusion locally, you can read this article here. Now back to the main topic :
How to Solve Black Screen Output Issue in Stable diffusion?
Apparently many users have been facing similar issues while using Automatic SD webui with lower vram graphic cards. The webui runs just fine but the output image turns out to be completely black. It’s prevalent with NVIDIA 16xx series of cards but also happened in some other cases too. If you are using a custom folder inside C drive to hold your ‘stable diffusion webui’ folder then first step would be get the ‘stable diffusion webui’ folder directly under C drive. The easiest way would be to just copy the folder and paste it directly under C drive. Next you have to do some coding. No need to be afraid, it’s just adding one line, that too will be provided in the article.
Find the webui-user file inside the ‘stable diffusion webui’ folder. Right click on the icon, press edit and a notepad document opens up. On the 5th line replace the command with, ‘set COMMANDLINE_ARGS=–precision full –no-half’, save the file. **Now open the SD and the issue of black output will be gone and now you can start dreaming.
How to Fix RuntimeError: CUDA out of memory in Stable Diffusion?
When the SD models runs out of available graphic memory, this error occurs. The easiest fix would be to just decrease the resolution of the image from 512×512 to even lower. In that way you can handle the error somehow. But if you want to keep generating images at 512×512 then keep reading.
Again go to the webui-user file and choose edit. Replace the ‘set COMMANDLINE_ARGS=–precision full –no-half’ or ‘set COMMANDLINE_ARGS=’, with ‘set COMMANDLINE_ARGS=–precision full –no-half –medvram –opt-split-attention’
This should solve the problem for most generations. But if you want to push the boundaries even farther or if your pc doesn’t support most options in the webui, try this code instead. ‘set COMMANDLINE_ARGS=–precision full –no-half –lowvram –always-batch-cond-uncond –opt-split-attention’ and save the file. This solved the problem for me.