comfyanonymous / ComfyUI

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface.
https://www.comfy.org/
GNU General Public License v3.0
49.86k stars 5.25k forks source link

Help, I do not know what operation, now comfyui will run an error #2314

Open gxbsyxh opened 8 months ago

gxbsyxh commented 8 months ago

Error occurred when executing KSamplerAdvanced:

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_CUDA_addmm)

File "D:\ComfyUI_windows_portable25\ComfyUI\execution.py", line 153, in recursive_execute output_data, output_ui = get_output_data(obj, input_data_all) File "D:\ComfyUI_windows_portable25\ComfyUI\execution.py", line 83, in get_output_data return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True) File "D:\ComfyUI_windows_portable25\ComfyUI\execution.py", line 76, in map_node_over_list results.append(getattr(obj, func)(slice_dict(input_data_all, i))) File "D:\ComfyUI_windows_portable25\ComfyUI\nodes.py", line 1333, in sample return common_ksampler(model, noise_seed, steps, cfg, sampler_name, scheduler, positive, negative, latent_image, denoise=denoise, disable_noise=disable_noise, start_step=start_at_step, last_step=end_at_step, force_full_denoise=force_full_denoise) File "D:\ComfyUI_windows_portable25\ComfyUI\nodes.py", line 1269, in common_ksampler samples = comfy.sample.sample(model, noise, steps, cfg, sampler_name, scheduler, positive, negative, latent_image, File "D:\ComfyUI_windows_portable25\ComfyUI\custom_nodes\ComfyUI-Impact-Pack\modules\impact\sample_error_enhancer.py", line 22, in informative_sample raise e File "D:\ComfyUI_windows_portable25\ComfyUI\custom_nodes\ComfyUI-Impact-Pack\modules\impact\sample_error_enhancer.py", line 9, in informative_sample return original_sample(*args, *kwargs) File "D:\ComfyUI_windows_portable25\ComfyUI\custom_nodes\ComfyUI-AnimateDiff-Evolved\animatediff\sampling.py", line 284, in motion_sample return wrap_function_to_inject_xformers_bug_info(orig_comfy_sample)(model, noise, args, kwargs) File "D:\ComfyUI_windows_portable25\ComfyUI\custom_nodes\ComfyUI-AnimateDiff-Evolved\animatediff\model_utils.py", line 205, in wrapped_function return function_to_wrap(args, kwargs) File "D:\ComfyUI_windows_portable25\ComfyUI\comfy\sample.py", line 100, in sample samples = sampler.sample(noise, positive_copy, negative_copy, cfg=cfg, latent_image=latent_image, start_step=start_step, last_step=last_step, force_full_denoise=force_full_denoise, denoise_mask=noise_mask, sigmas=sigmas, callback=callback, disable_pbar=disable_pbar, seed=seed) File "D:\ComfyUI_windows_portable25\ComfyUI\comfy\samplers.py", line 716, in sample return sample(self.model, noise, positive, negative, cfg, self.device, sampler, sigmas, self.model_options, latent_image=latent_image, denoise_mask=denoise_mask, callback=callback, disable_pbar=disable_pbar, seed=seed) File "D:\ComfyUI_windows_portable25\ComfyUI\comfy\samplers.py", line 622, in sample samples = sampler.sample(model_wrap, sigmas, extra_args, callback, noise, latent_image, denoise_mask, disable_pbar) File "D:\ComfyUI_windows_portable25\ComfyUI\comfy\samplers.py", line 561, in sample samples = self.sampler_function(model_k, noise, sigmas, extra_args=extra_args, callback=k_callback, disable=disable_pbar, self.extra_options) File "D:\ComfyUI_windows_portable25\python_embeded\Lib\site-packages\torch\utils_contextlib.py", line 115, in decorate_context return func(args, kwargs) File "D:\ComfyUI_windows_portable25\ComfyUI\comfy\k_diffusion\sampling.py", line 137, in sample_euler denoised = model(x, sigma_hat * s_in, *extra_args) File "D:\ComfyUI_windows_portable25\python_embeded\Lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl return forward_call(args, kwargs) File "D:\ComfyUI_windows_portable25\ComfyUI\comfy\samplers.py", line 285, in forward out = self.inner_model(x, sigma, cond=cond, uncond=uncond, cond_scale=cond_scale, model_options=model_options, seed=seed) File "D:\ComfyUI_windows_portable25\python_embeded\Lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl return forward_call(*args, kwargs) File "D:\ComfyUI_windows_portable25\ComfyUI\comfy\samplers.py", line 275, in forward return self.apply_model(*args, *kwargs) File "D:\ComfyUI_windows_portable25\ComfyUI\comfy\samplers.py", line 272, in apply_model out = sampling_function(self.inner_model, x, timestep, uncond, cond, cond_scale, model_options=model_options, seed=seed) File "D:\ComfyUI_windows_portable25\ComfyUI\custom_nodes\ComfyUI-AnimateDiff-Evolved\animatediff\sampling.py", line 632, in sliding_sampling_function cond, uncond = calc_cond_uncond_batch(model, cond, uncond, x, timestep, model_options) File "D:\ComfyUI_windows_portable25\ComfyUI\custom_nodes\ComfyUI-AnimateDiff-Evolved\animatediff\sampling.py", line 488, in calc_cond_uncond_batch c['control'] = control.get_control(inputx, timestep, c, len(cond_or_uncond)) File "D:\ComfyUI_windows_portable25\ComfyUI\custom_nodes\ComfyUI-Advanced-ControlNet\control\control.py", line 185, in get_control return self.sliding_get_control(x_noisy, t, cond, batched_number) File "D:\ComfyUI_windows_portable25\ComfyUI\custom_nodes\ComfyUI-Advanced-ControlNet\control\control.py", line 243, in sliding_get_control control = self.control_model(x=x_noisy.to(self.control_model.dtype), hint=self.cond_hint, timesteps=timestep.float(), context=context.to(self.control_model.dtype), y=y) File "D:\ComfyUI_windows_portable25\python_embeded\Lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl return forward_call(args, kwargs) File "D:\ComfyUI_windows_portable25\ComfyUI\comfy\cldm\cldm.py", line 287, in forward emb = self.time_embed(t_emb) File "D:\ComfyUI_windows_portable25\python_embeded\Lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl return forward_call(*args, *kwargs) File "D:\ComfyUI_windows_portable25\python_embeded\Lib\site-packages\torch\nn\modules\container.py", line 217, in forward input = module(input) File "D:\ComfyUI_windows_portable25\python_embeded\Lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl return forward_call(args, **kwargs) File "D:\ComfyUI_windows_portable25\python_embeded\Lib\site-packages\torch\nn\modules\linear.py", line 114, in forward return F.linear(input, self.weight, self.bias)

MarcinSoj commented 8 months ago

Hi try to use : --disable-cuda-malloc in your run_nvidia_gpu.bat file.

So output will be like this: .\python_embeded\python.exe -s ComfyUI\main.py --windows-standalone-build --lowvram --preview-method auto --bf16-vae --disable-cuda-malloc

gxbsyxh commented 8 months ago

Hi try to use : --disable-cuda-malloc in your run_nvidia_gpu.bat file.

So output will be like this: .\python_embeded\python.exe -s ComfyUI\main.py --windows-standalone-build --lowvram --preview-method auto --bf16-vae --disable-cuda-malloc

Thank you very much for your help.I have been troubled for a week, and now I can work normally. May I ask you again about the usefulness and impact of this added code? If it can only work if you keep it for the future

MarcinSoj commented 8 months ago

Hi try to use : --disable-cuda-malloc in your run_nvidia_gpu.bat file. So output will be like this: .\python_embeded\python.exe -s ComfyUI\main.py --windows-standalone-build --lowvram --preview-method auto --bf16-vae --disable-cuda-malloc

Thank you very much for your help.I have been troubled for a week, and now I can work normally. May I ask you again about the usefulness and impact of this added code? If it can only work if you keep it for the future

I am glad it helped y friend :)

"What is Unified Memory?

Unified Memory is a single memory address space accessible from any processor in a system (see Figure 1). This hardware/software technology allows applications to allocate data that can be read or written from code running on either CPUs or GPUs. Allocating Unified Memory is as simple as replacing calls to malloc() or new with calls to cudaMallocManaged(), an allocation function that returns a pointer accessible from any processor (ptr in the following).

cudaError_t cudaMallocManaged(void** ptr, size_t size);

When code running on a CPU or GPU accesses data allocated this way (often called CUDA managed data), the CUDA system software and/or the hardware takes care of migrating memory pages to the memory of the accessing processor. The important point here is that the Pascal GPU architecture is the first with hardware support for virtual memory page faulting and migration, via its Page Migration Engine. Older GPUs based on the Kepler and Maxwell architectures also support a more limited form of Unified Memory."

This is basically the explanation what it is used for.

source: https://developer.nvidia.com/blog/unified-memory-cuda-beginners/

Good luck next time :)

gxbsyxh commented 8 months ago

Thanks for MarcinSoj's help, after a separate node test, we found the problem https://github.com/banodoco/Steerable-Motion/issues/11 ComfyUI-Advanced-ControlNet needs to be updated to work, leaving it for friends who find problems later

chdelacr commented 8 months ago

I'm getting the same exact error and I'm not using ControlNet nodes.

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