sd-webui-controlnet icon indicating copy to clipboard operation
sd-webui-controlnet copied to clipboard

How to fix the 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 mat1 in method wrapper_addmm

Open Zenzen007 opened this issue 1 year ago • 1 comments

When I use the '--medvram', I encounter a RuntimeError as mentioned earlier. However, if I do not use the '--medvram', Controlnet functions properly.

this is the error code

ffmpeg version 2023-03-02-git-814178f926-full_build-www.gyan.dev Copyright (c) 2000-2023 the FFmpeg developers built with gcc 12.2.0 (Rev10, Built by MSYS2 project) configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libvpl --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint libavutil 58. 3.100 / 58. 3.100 libavcodec 60. 5.100 / 60. 5.100 libavformat 60. 4.100 / 60. 4.100 libavdevice 60. 2.100 / 60. 2.100 libavfilter 9. 4.100 / 9. 4.100 libswscale 7. 2.100 / 7. 2.100 libswresample 4. 11.100 / 4. 11.100 libpostproc 57. 2.100 / 57. 2.100 Input #0, png_pipe, from 'C:\Users\ZenJangz\AppData\Local\Temp\posehtwcndha.png': Duration: N/A, bitrate: N/A Stream #0:0: Video: png, rgba(pc, gbr/bt709/iec61966-2-1), 512x512, 25 fps, 25 tbr, 25 tbn Stream mapping: Stream #0:0 -> #0:0 (png (native) -> h264 (libx264)) Press [q] to stop, [?] for help [libx264 @ 0000022df35c8b00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2 [libx264 @ 0000022df35c8b00] profile High 4:4:4 Predictive, level 3.0, 4:4:4, 8-bit [libx264 @ 0000022df35c8b00] 264 - core 164 r3106 eaa68fa - H.264/MPEG-4 AVC codec - Copyleft 2003-2023 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=4 threads=16 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00 Output #0, mp4, to 'C:\Users\ZenJangz\AppData\Local\Temp\posehtwcndha.mp4': Metadata: encoder : Lavf60.4.100 Stream #0:0: Video: h264 (avc1 / 0x31637661), yuv444p(tv, unknown/bt709/iec61966-2-1, progressive), 512x512, q=2-31, 25 fps, 12800 tbn Metadata: encoder : Lavc60.5.100 libx264 Side data: cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A frame= 1 fps=0.0 q=28.0 Lsize= 4kB time=00:00:00.00 bitrate=N/A speed= 0x eed=N/A video:3kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 24.495848% [libx264 @ 0000022df35c8b00] frame I:1 Avg QP:26.72 size: 2683 [libx264 @ 0000022df35c8b00] mb I I16..4: 3.2% 84.8% 12.0% [libx264 @ 0000022df35c8b00] 8x8 transform intra:84.8% [libx264 @ 0000022df35c8b00] coded y,u,v intra: 7.5% 5.9% 6.0% [libx264 @ 0000022df35c8b00] i16 v,h,dc,p: 52% 36% 12% 0% [libx264 @ 0000022df35c8b00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 42% 22% 36% 0% 0% 0% 0% 0% 0% [libx264 @ 0000022df35c8b00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 59% 22% 8% 1% 1% 4% 1% 2% 1% [libx264 @ 0000022df35c8b00] kb/s:536.60 Loading model: control_sd15_openpose [fef5e48e] Loaded state_dict from [C:\stable-diffusion-webui\extensions\sd-webui-controlnet\models\control_sd15_openpose.pth] ControlNet model control_sd15_openpose [fef5e48e] loaded. Loading preprocessor: none 0%| | 0/20 [00:04<?, ?it/s] Error completing request Arguments: ('task(0cfdsrdib6mivzz)', '1girl', '', [], 20, 0, False, False, 1, 1, 7, -1.0, -1.0, 0, 0, 0, False, 512, 512, False, 0.7, 2, 'Latent', 0, 0, 0, [], 0, False, True, 'none', 'control_sd15_openpose [fef5e48e]', 1, {'image': array([[[0, 0, 0], [0, 0, 0], [0, 0, 0], ..., [0, 0, 0], [0, 0, 0], [0, 0, 0]],

   [[0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
    ...,
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0]],

   [[0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
    ...,
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0]],

   ...,

   [[0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
    ...,
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0]],

   [[0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
    ...,
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0]],

   [[0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
    ...,
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0]]], dtype=uint8), 'mask': array([[[  0,   0,   0, 255],
    [  0,   0,   0, 255],
    [  0,   0,   0, 255],
    ...,
    [  0,   0,   0, 255],
    [  0,   0,   0, 255],
    [  0,   0,   0, 255]],

   [[  0,   0,   0, 255],
    [  0,   0,   0, 255],
    [  0,   0,   0, 255],
    ...,
    [  0,   0,   0, 255],
    [  0,   0,   0, 255],
    [  0,   0,   0, 255]],

   [[  0,   0,   0, 255],
    [  0,   0,   0, 255],
    [  0,   0,   0, 255],
    ...,
    [  0,   0,   0, 255],
    [  0,   0,   0, 255],
    [  0,   0,   0, 255]],

   ...,

   [[  0,   0,   0, 255],
    [  0,   0,   0, 255],
    [  0,   0,   0, 255],
    ...,
    [  0,   0,   0, 255],
    [  0,   0,   0, 255],
    [  0,   0,   0, 255]],

   [[  0,   0,   0, 255],
    [  0,   0,   0, 255],
    [  0,   0,   0, 255],
    ...,
    [  0,   0,   0, 255],
    [  0,   0,   0, 255],
    [  0,   0,   0, 255]],

   [[  0,   0,   0, 255],
    [  0,   0,   0, 255],
    [  0,   0,   0, 255],
    ...,
    [  0,   0,   0, 255],
    [  0,   0,   0, 255],
    [  0,   0,   0, 255]]], dtype=uint8)}, False, 'Scale to Fit (Inner Fit)', False, True, 64, 64, 64, 0, 1, False, False, False, 'positive', 'comma', 0, False, False, '', 1, '', 0, '', 0, '', True, False, False, False, 0, 'C:\\Users\\ZenJangz\\AppData\\Local\\Temp\\posehtwcndha.mp4', 50) {}

Traceback (most recent call last): File "C:\stable-diffusion-webui\modules\call_queue.py", line 56, in f res = list(func(*args, **kwargs)) File "C:\stable-diffusion-webui\modules\call_queue.py", line 37, in f res = func(*args, **kwargs) File "C:\stable-diffusion-webui\modules\txt2img.py", line 56, in txt2img processed = process_images(p) File "C:\stable-diffusion-webui\modules\processing.py", line 486, in process_images res = process_images_inner(p) File "C:\stable-diffusion-webui\modules\processing.py", line 632, in process_images_inner samples_ddim = p.sample(conditioning=c, unconditional_conditioning=uc, seeds=seeds, subseeds=subseeds, subseed_strength=p.subseed_strength, prompts=prompts) File "C:\stable-diffusion-webui\modules\processing.py", line 832, in sample samples = self.sampler.sample(self, x, conditioning, unconditional_conditioning, image_conditioning=self.txt2img_image_conditioning(x)) File "C:\stable-diffusion-webui\modules\sd_samplers_kdiffusion.py", line 349, in sample samples = self.launch_sampling(steps, lambda: self.func(self.model_wrap_cfg, x, extra_args={ File "C:\stable-diffusion-webui\modules\sd_samplers_kdiffusion.py", line 225, in launch_sampling return func() File "C:\stable-diffusion-webui\modules\sd_samplers_kdiffusion.py", line 349, in samples = self.launch_sampling(steps, lambda: self.func(self.model_wrap_cfg, x, extra_args={ File "C:\stable-diffusion-webui\venv\lib\site-packages\torch\autograd\grad_mode.py", line 27, in decorate_context return func(*args, **kwargs) File "C:\stable-diffusion-webui\repositories\k-diffusion\k_diffusion\sampling.py", line 145, in sample_euler_ancestral denoised = model(x, sigmas[i] * s_in, **extra_args) File "C:\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1194, in _call_impl return forward_call(*input, **kwargs) File "C:\stable-diffusion-webui\modules\sd_samplers_kdiffusion.py", line 123, in forward x_out[a:b] = self.inner_model(x_in[a:b], sigma_in[a:b], cond={"c_crossattn": [cond_in[a:b]], "c_concat": [image_cond_in[a:b]]}) File "C:\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1194, in _call_impl return forward_call(*input, **kwargs) File "C:\stable-diffusion-webui\repositories\k-diffusion\k_diffusion\external.py", line 112, in forward eps = self.get_eps(input * c_in, self.sigma_to_t(sigma), **kwargs) File "C:\stable-diffusion-webui\repositories\k-diffusion\k_diffusion\external.py", line 138, in get_eps return self.inner_model.apply_model(*args, **kwargs) File "C:\stable-diffusion-webui\modules\sd_hijack_utils.py", line 17, in setattr(resolved_obj, func_path[-1], lambda *args, **kwargs: self(*args, **kwargs)) File "C:\stable-diffusion-webui\modules\sd_hijack_utils.py", line 28, in call return self.__orig_func(*args, **kwargs) File "C:\stable-diffusion-webui\repositories\stable-diffusion-stability-ai\ldm\models\diffusion\ddpm.py", line 858, in apply_model x_recon = self.model(x_noisy, t, **cond) File "C:\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1212, in _call_impl result = forward_call(*input, **kwargs) File "C:\stable-diffusion-webui\repositories\stable-diffusion-stability-ai\ldm\models\diffusion\ddpm.py", line 1329, in forward out = self.diffusion_model(x, t, context=cc) File "C:\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1194, in _call_impl return forward_call(*input, **kwargs) File "C:\stable-diffusion-webui\extensions\sd-webui-controlnet\scripts\hook.py", line 212, in forward2 return forward(*args, **kwargs) File "C:\stable-diffusion-webui\extensions\sd-webui-controlnet\scripts\hook.py", line 179, in forward emb = self.time_embed(t_emb) File "C:\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1194, in _call_impl return forward_call(*input, **kwargs) File "C:\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\container.py", line 204, in forward input = module(input) File "C:\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1194, in _call_impl return forward_call(*input, **kwargs) File "C:\stable-diffusion-webui\extensions-builtin\Lora\lora.py", line 178, in lora_Linear_forward return lora_forward(self, input, torch.nn.Linear_forward_before_lora(self, input)) File "C:\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\linear.py", line 114, in forward return F.linear(input, self.weight, self.bias) 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 mat1 in method wrapper_addmm)

Zenzen007 avatar Mar 05 '23 17:03 Zenzen007

This is related to low VRAM or SLI. In this case, you should use the option (Low VRAM) next RGB to BGR.

AIAMIAUTHOR avatar Mar 12 '23 01:03 AIAMIAUTHOR