AI Art Generation Handbook/List of Issues and possible Solutions

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Here is the list of the problems that might be faced during installations and/or during normal usage of Stable Diffusion

P.S 1 : Press "Ctrl" + "F" in your browser to see if you facing certain issues for fast searchig

P.S: If there are other error / problems that you faced during the installing / generating images, you can add your own answer here. Or put it in the Discussion tabs.

General Use[edit | edit source]

(1) CUDA Out of Memory

Descriptions
Affected Web-UI / System Automatic 1111 / Windows
Error message Depending on WebUI versions:

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

Description When running Stable Diffusion to generate the first image, generated images would not show at all and show "Error" at where the image supposedly be appeared.

When open the command shell window, error message will come out

Workaround /Solution (i) Ensure the hardware requirements of VRAM (Not RAM) is 4GB and above. Optimally, recommended to buy any graphic card that supported 6GB VRAM and above.

If you decide want to train the model using Dreambooth , suggest to use Google Collabs or buying the graphic card that supported 12GB VRAM or above.|

(ii) In the webui-user.bat file, right click to edit the files using notepad.

At the line where set " COMMANDLINE_ARGS = " , add in these parameters " --xformers " and " --medvram " and " --opt-split-attention " to reduce further the VRAM needed BUT it will added the processing time.


(2) Images does not show up on image view panels after generated images

Descriptions
Affected Web-UI / System Automatic 1111 / Windows
Error message AttributeError: 'Blocks' object has no attribute 'temp_file_sets' on the command shell window
Description This error message appeared during the update of Automatic 1111 (Jan 2023 update) with Dreambooth installed successfully where the image generated are not shown on the image preview gallery on the right panel.

Further troubleshooting revealed that there are error message (shown above) that are suspected to be root cause of this issues

Workaround /Solution At the moment, to review your imgages , need to go to C:Your_Installed_Locations\stable-diffusion-webui\outputs to manually review the generated AI images.

Pending for Automatic 1111 to fix the issues


(3) Web-UI did not detect base model for AI art generations

Descriptions
Affected Web-UI / System Automatic 1111 / Windows
Error message No checkpoints found. When searching for checkpoints, looked at: - file C:\Your_Installed_Locations\stable-diffusion-webui\model.ckpt

- directory C:\Your_Installed_Locations\stable-diffusion-webui\models\Stable-diffusion

Can't run without a checkpoint. Find and place a .ckpt file into any of those locations. The program will exit. on the command shell window

Description This error message appeared during the installation of Stable Diffusions for the first time on the system itself.
Workaround /Solution Download the models from the link here https://huggingface.co/runwayml/stable-diffusion-v1-5/tree/main and copy the models (.ckpt) files to the C:\Your_Installed_Locations\stable-diffusion-webui\models\Stable-diffusion


(4) Unable to generate images - TypeError: 'NoneType' object is not callable

Descriptions
Affected Web-UI / System SD.Next with SDXL Model/ Windows
Error message TypeError: 'NoneType' object is not callable
Description This error message appeared when want to generate AI images with the images unable to be generated
Workaround /Solution Disable extensions named a1111-sd-webui-lycoris by untick it on the left side and update to latest patch whenever available (Aug 2023)


SDXL related[edit | edit source]

(1) Web-UI generates only black images (For SDXL models)

Descriptions
Affected Web-UI / System SD.Next with SDXL Model/ Windows
Error message Error loading model weights:

                         C:\Your_installed_directory\SD.Next\automatic\models\Stable-diffusion\sd_xl_base_1.0.safe

                         tensors Error(s) in loading state_dict for LatentDiffusion:

                                 size mismatch for model.diffusion_model.input_blocks.4.1.proj_in.weight: copying a

                         param with shape torch.Size([640, 640]) from checkpoint, the shape in current model is

                         torch.Size([640, 640, 1, 1]).

                                 size mismatch for

                         model.diffusion_model.input_blocks.4.1.transformer_blocks.0.attn2.to_k.weight: copying a param

                         with shape torch.Size([640, 2048]) from checkpoint, the shape in current model is

                         torch.Size([640, 768]).

Description When you want to try the latest Stable Diffusion SDXL model, it will just generate black images only
Workaround /Solution On the tab , click on Settings top tab , User Interface at the right side , scroll down to the Quicksettings list . Add in by typing

sd_model_checkpoint , sd_model_refiner , diffuser pipeline and sd_backend . Scroll back to top to click on Apply Settings .and then click Restart Server button . (But highly suggest to close all of terminal windows ) and re-click webui.bat

Once clicked, you should be re-directed back to the main page .

(2) Web-UI generates only cartoon abstract art / line art image although you try to generate photographs like image

Descriptions
Affected Web-UI / System Auto1111 with SDXL Model, SD.Next with SDXL Model/ Windows
Error message N/A
Description When you want to try the latest Stable Diffusion SDXL model, it will just generate cartoony or at worst images
Workaround /Solution (i) Generate the image more than 512*512px size (See this link > AI Art Generation Handbook/Differing Resolution for SDXL ) . For most optimum result, choose 1024 * 1024 px images

(ii) Use negative prompts such as cartoon , anime , drawings to enhance the photorealism (if you want to achieve it)

ControlNet[edit | edit source]

(1) ControlNet Canny is generating a cartoony images

Descriptions
Affected Web-UI / System Auto1111 with SDXL Model, ControlNet Canny XL
Error message RuntimeError: You have not selected any ControlNet Model.
Description When you want to try to generate a Canny preprocessed but it is generating cartoonish images
Workaround /Solution (1) Lower down the weight seems helpful (more testing needed)


(2) mat1 and mat2 shapes cannot be multiplied (154x2048 and 768x320)

Descriptions
Affected Web-UI / System Auto1111 with SDXL Model, ControlNet_sd15
Error message mat1 and mat2 shapes cannot be multiplied (154x2048 and 768x320)
Description Images unable to be generated and the error message RuntimeError: mat1 and mat2 shapes cannot be multiplied (154x2048 and 768x320) is shown on the webui and terminal
Workaround /Solution (i) Ensure the Stable Diffusion Checkpoint(on top left) and ControlNet model (beside Preprocessor) should be same. (Meaning if base model is SDXL , ensure ControlNet is also same SDXL)

Captioning[edit | edit source]

(1) When using webp images , error message with O with slash above O will appear

Descriptions
Affected Web-UI / System Automatic 1111 / Windows
Error message   File "C:\Your_Installed_Locations\Python\Python310\lib\encodings\cp1252.py", line 19, in encode return codecs.charmap_encode(input,self.errors,encoding_table)[0]

UnicodeEncodeError: 'charmap' codec can't encode character '\u014d' in position 118: character maps to <undefined> on the command shell window

Description If you captioning on webp image format, it might appeared from time to time
Workaround /Solution (i) Try to convert the images to png and retry captioning

(ii) If errors persists, use other images instead

(iii) Wait for Automatic1111 to fix the issues

Installation[edit | edit source]

(1) Pytorch / Torch Vision error when installing Auto1111

Descriptions
Affected Web-UI / System Automatic 1111 / Windows
Error message RuntimeError: Couldn't install torchstderr: ERROR: Could not find a version that satisfies the requirement torch==x.xx.x +cu yyy (from versions: none)

ERROR: No matching distribution found for torch==x.xx.x +cu yyy on the command shell window

Description This error message appeared during/after the installation of Stable Diffusions for the first time on the system itself. The Web-UI unable to load and the error message closes itself.

Futher troubleshooting leads to Pytorch / Torch Vision are unable to caught up to the latest version of Pyton.

Workaround / Solution (i) Type the cmd command at the Your_Installation_Locations and type python --version .Check back on the software pre-requisites and see if the Python version number is higher than the recommended version.

If higher, recommended to download and re-install the same version as of recommended Python version (3.10.9) or can try to dial back a few versions backward.


(ii) If error persists after step (i), delete the venv folder aka C:\Your_Installed_Locations\stable-diffusion-webui\venv and restart the Web-UI (click webui-user.bat) to re-generate the Python Enviroment due to conflict merging

Note: Pytorch development usually are not able to caught onto the latest version of Python.

Extension[edit | edit source]

(1) Extension lists is not loading

Descriptions
Affected Web-UI / System Automatic 1111 / Windows
Error message ValueError: unknown url type: '' [object Object] on theweb-ui

TypeError: unhashable type: 'dict' on the command shell window

Description When want to add extension, the lists is empty, when it is supposedly full
Workaround / Solution (i) Restart the whole web-ui

(ii) If error persisted, check for values in Extension -> Available -> Extension index URL . If the URL field is empty , copy this field below and click Load From button :

https://raw.githubusercontent.com/wiki/AUTOMATIC1111/stable-diffusion-webui/Extensions-index.md


(2) Extension not updating

Descriptions
Affected Web-UI / System Automatic 1111 / Windows
Error message Update: Unknown on the web-ui shown
Description This error is applicable if you installed dreambooth
Workaround / Solution (i) Delete all the extensions installed in ControlnetDreamboothStableDiffusion\stable-diffusion-webui\extensions

(ii) Restart the web-ui (iii) Reinstall all of previous extension but DO NOT install dreambooth

Dreambooth[edit | edit source]

Znak A-30 As of this moment, training using Dreambooth extension for A1111 are not encouraged to be used as it is bug breaking. Recommend to use kohya-ss

(1) Dreambooth installation error / Dreambooth not appearing on the main page tabs

Descriptions
Affected Web-UI / System Automatic 1111 / Windows
Error message Depending on the Automatic1111 versions, you may unable to proceed with Stable Diffusion with the following error messages

ImportError: DLL load failed while importing _ufuncs: %1 is not a valid Win32 application
Error loading script: api.py
Error loading script: dreambooth.py
Error loading script: main.py

Description Depending on the Automatic1111 version, several symptoms may appeared:

(i) Web-UI is unable to be opened at all and shows ImportError message in Command Windows
(ii) After installing Dreambooth in the Automatic1111, there are no tabs "Dreambooth" appeared between Training and Setting tab.

Workaround /Solution Re-install the whole Stable Diffusion from scratch [ See this link for step by step details ] and make sure that folder name (aka "Your_Installed_Locations") should NOT HAVE ANY EMPTY SPACES in the folder naming

NG E.g: "Stable Diffusion Dreambooth" is Cross-image (Unless you intend to generate images only)
OK E.g: "StableDiffusionDreambooth" or "Stable_Diffusion_Dreambooth" is Tick, Web Fundamentals

or delete the venv folder aka C:\Your_Installed_Locations\stable-diffusion-webui\venv and restart the Web-UI (click webui-user.bat) to re-generate the Python Enviroment due to conflict merging

or pending for Automatic1111 to provide fix in future versions

(2) File Not found when installing Dreambooth

Descriptions
Affected Web-UI / System Automatic 1111 / Windows
Error message stderr: ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: 'C:\\Your_Installed_Locations\\stable-diffusion-webui\\venv\\Lib\\site-packages\\tensorflow\\include\\external\\llvm-project\\mlir\\_virtual_includes\\BufferizableOpInterfaceIncGen\\mlir\\Dialect\\Bufferization\\IR\\BufferizableOpInterface.cpp.inc'HINT: This error might have occurred since this system does not have Windows Long Path support enabled. You can find information on how to enable this at https://pip.pypa.io/warnings/enable-long-paths
Description When installing Dreambooth for Stable Diffusion, the above messages may occurs
Workaround /Solution (i) Create a .reg files on any where at the PC system

(ii) Paste following codes inside the .reg file

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem]

"LongPathsEnabled"=dword:00000001

(iii) Double click the .reg file to execute

(iv) Re-install the Web-UI from scratch

(3) Invalid training data directory.

Descriptions
Affected Web-UI / System Automatic 1111 / Windows
Error message Invalid training data directory.
Description When want to click Training button in Dreambooth tab for Stable Diffusion, the above messages may occurs
Workaround /Solution Make sure before training, the button "Create Model" in Create tab must be clicked before proceed to train the model

(4) Pip Installation Error

Descriptions
Affected Web-UI / System Automatic 1111 / Windows
Error message Fatal error in launcher: Unable to create process using '"Your Installation Directory\venv\Scripts\python.exe" .
Description When installing the latest version of dreambooth which requires Torch 2, you encounter the following error while following instructions from this Github link
Workaround /Solution It meant that your pip version is not upgraded to Torch 2 installation requirements

To resolve this, type this before start the command listed on the link python -m ensurepip --upgrade python -m pip install --upgrade pip