lllyasviel / lllyasviel/stable-diffusion-webui-forge

Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0!

Open
#2,586 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
13k
Forks
1.7k
PR merge metrics
No merged PRs in 30d

Description

Get error while trying to do something in controlnet integrated

Help me please! :(

System info: Win 10, RTX 2070 super 8 gb

Using model: dreamshaperXL_v21TurboDPMSDE.safetensors ,

Arguments:@echo off

set PATH=D:\ffmpeg-7.1\bin;%PATH%

set PYTHON=

set GIT=

set VENV_DIR=

set COMMANDLINE_ARGS=--xformers --medvram --cuda-stream --cuda-malloc --always-offload-from-vram --opt-sdp-attention --theme dark

git pull

call webui.bat

https://imgur.com/a/00loYDf

*** Error running process_before_every_sampling: D:\newstablediff\webui\extensions-builtin\sd_forge_controlnet\scripts\controlnet.py
Traceback (most recent call last):
File "D:\newstablediff\webui\modules\scripts.py", line 892, in process_before_every_sampling
script.process_before_every_sampling(p, *script_args, **kwargs)
File "D:\newstablediff\webui\venv\lib\site-packages\torch\utils\_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
File "D:\newstablediff\webui\extensions-builtin\sd_forge_controlnet\scripts\controlnet.py", line 561, in process_before_every_sampling
self.process_unit_before_every_sampling(p, unit, self.current_params[i], *args, **kwargs)
File "D:\newstablediff\webui\venv\lib\site-packages\torch\utils\_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
File "D:\newstablediff\webui\extensions-builtin\sd_forge_controlnet\scripts\controlnet.py", line 507, in process_unit_before_every_sampling
params.model.process_before_every_sampling(p, cond, mask, *args, **kwargs)
File "D:\newstablediff\webui\extensions-builtin\sd_forge_ipadapter\scripts\forge_ipadapter.py", line 147, in process_before_every_sampling
unet = opIPAdapterApply(
File "D:\newstablediff\webui\extensions-builtin\sd_forge_ipadapter\lib_ipadapter\IPAdapterPlus.py", line 688, in apply_ipadapter
clip_embed = clip_vision.encode_image(image)
File "D:\newstablediff\webui\backend\patcher\clipvision.py", line 123, in encode_image
outputs = self.model(pixel_values=pixel_values, output_hidden_states=True)
File "D:\newstablediff\webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1532, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "D:\newstablediff\webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1541, in _call_impl
return forward_call(*args, **kwargs)
File "D:\newstablediff\webui\venv\lib\site-packages\transformers\models\clip\modeling_clip.py", line 1483, in forward
vision_outputs = self.vision_model(
File "D:\newstablediff\webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1532, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "D:\newstablediff\webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1541, in _call_impl
return forward_call(*args, **kwargs)
File "D:\newstablediff\webui\venv\lib\site-packages\transformers\models\clip\modeling_clip.py", line 1029, in forward
hidden_states = self.embeddings(pixel_values)
File "D:\newstablediff\webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1532, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "D:\newstablediff\webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1541, in _call_impl
return forward_call(*args, **kwargs)
File "D:\newstablediff\webui\venv\lib\site-packages\transformers\models\clip\modeling_clip.py", line 195, in forward
embeddings = torch.cat([class_embeds, patch_embeds], dim=1)
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 tensors in method wrapper_CUDA_cat)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the ControlNet/IP-Adapter path described in extensions-builtin/sd_forge_controlnet/scripts/controlnet.py and extensions-builtin/sd_forge_ipadapter/lib_ipadapter/IPAdapterPlus.py. Start at clipvision.py:123 and the Transformers CLIP stack trace, then determine where CPU and cuda:0 tensors diverge; done means this sampling workflow no longer raises the device-mismatch error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
computer-vision, machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.