Comments (11)
As a workaround set the environment variable ONEDNN_MAX_CPU_ISA=AVX2
when launching ComfyUI
from comfyui-inpaint-nodes.
It does create the suspicion that it's a bug in torch 2.2.0. But because it seems to only happen for few people and I can't reproduce it myself at all even with 2.2.0, makes it difficult to investigate further or report it.
from comfyui-inpaint-nodes.
You're not the only one: Acly/krita-ai-diffusion#401
But it only happens on some systems it seems, I can't reproduce it myself. If you can share your python & torch version it might help.
Note that this usually runs on CPU like most image operations
from comfyui-inpaint-nodes.
You're not the only one: Acly/krita-ai-diffusion#401 But it only happens on some systems it seems, I can't reproduce it myself. If you can share your python & torch version it might help. Note that this usually runs on CPU like most image operations
Hi, thanks, I checked that thread.
Python 3.11.7
Torch version: 2.2.0+cu121
I am running a AMD 7950x CPU
I downgraded pytorch to 2.1.1 - It worked.
Doesn't work with 2.2.0.
from comfyui-inpaint-nodes.
You're not the only one: Acly/krita-ai-diffusion#401 But it only happens on some systems it seems, I can't reproduce it myself. If you can share your python & torch version it might help. Note that this usually runs on CPU like most image operations
So basically, I made some changes. I am not a coder, i have zero python coding knowledge, this was with the help of chatgpt.
It advised to move the function from cpu to gpu. I am not sure how optimized this is, but have a look.
nodes.py
class MaskedBlur:
@classmethod
def INPUT_TYPES(s):
return {
"required": {
"image": ("IMAGE",),
"mask": ("MASK",),
"blur": ("INT", {"default": 255, "min": 3, "max": 8191, "step": 1}),
"falloff": ("INT", {"default": 0, "min": 0, "max": 8191, "step": 1}),
}
}
RETURN_TYPES = ("IMAGE",)
CATEGORY = "inpaint"
FUNCTION = "fill"
def fill(self, image: Tensor, mask: Tensor, blur: int, falloff: int):
device = 'cuda' if torch.cuda.is_available() else 'cpu'
image, mask = to_torch(image, mask, device=device)
blur = make_odd(blur)
falloff = min(make_odd(falloff), blur - 2)
original = image.clone()
alpha = mask.floor()
if falloff > 0:
erosion = binary_erosion(alpha, falloff)
alpha = alpha * gaussian_blur(erosion, falloff)
alpha = alpha.repeat(1, 3, 1, 1)
image = gaussian_blur(image, blur)
image = original + (image - original) * alpha
return (to_comfy(image),)
util.py
def to_torch(image: Tensor, mask: Tensor | None = None, device=None):
if len(image.shape) == 3:
image = image.unsqueeze(0)
image = image.permute(0, 3, 1, 2) # BHWC to BCHW
if mask is not None:
if len(mask.shape) == 2:
mask = mask.unsqueeze(0).unsqueeze(0) # HWC to BCHW
elif len(mask.shape) == 3:
mask = mask.unsqueeze(1) # BHW to BCHW
if device:
image = image.to(device)
if mask is not None:
mask = mask.to(device)
return image, mask
After this I got error in the nodes.py folder located here: ComfyUI_windows_portable\ComfyUI
File "Q:\ComfyUI\ComfyUI_windows_portable\ComfyUI\nodes.py", line 415, in encode
pixels[:,:,:,i] *= m
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
It then advised me to add the following:
m = m.to(pixels.device)
before
pixels[:,:,:,i] *= m
(@line 415)
This is under "class InpaintModelConditioning:"
After this it works perfectly.
Please advise if the coding is proper? If not can you please update it appropriately, so everything is run by GPU and not the CPU.
from comfyui-inpaint-nodes.
It runs on CPU intentionally. While moving it to GPU may be a workaround, it doesn't really explain why it fails on CPU.
All image pre-preprocessing typically runs on CPU in ComfyUI, there are some things that are actually cheaper to do there, and going back and forth between CPU/GPU has a noticeable cost - so you usually only do it for heavy work.
A blur is kind of borderline heavy work though, so it could boil down to similar performance (depending on your CPU and GPU speed).
from comfyui-inpaint-nodes.
It runs on CPU intentionally. While moving it to GPU may be a workaround, it doesn't really explain why it fails on CPU.
All image pre-preprocessing typically runs on CPU in ComfyUI, there are some things that are actually cheaper to do there, and going back and forth between CPU/GPU has a noticeable cost - so you usually only do it for heavy work.
A blur is kind of borderline heavy work though, so it could boil down to similar performance (depending on your CPU and GPU speed).
It works with downgraded torch 2.1.1
Does that help?
from comfyui-inpaint-nodes.
Hi, I'm having the same problem. I seem to have a latest and updated comfyui. Is there any solution easier than replacing the lines of code above?
from comfyui-inpaint-nodes.
As a workaround set the environment variable
ONEDNN_MAX_CPU_ISA=AVX2
when launching ComfyUI
THANK YOU!!
from comfyui-inpaint-nodes.
As a workaround set the environment variable
ONEDNN_MAX_CPU_ISA=AVX2
when launching ComfyUI在启动 ComfyUI 时设置环境变量ONEDNN_MAX_CPU_ISA=AVX2
作为一种解决方法
THANK YOU!
from comfyui-inpaint-nodes.
Stable version of torch 2.3.0 has been released, this should no longer be an issue there.
from comfyui-inpaint-nodes.
Related Issues (20)
- Please do a workflow to add objects,
- Module 'nodes' has no attribute 'InpaintModelConditioning' HOT 3
- Unable to draw a delicate face HOT 5
- Error when executing INPAINT_LoadFooocusInpaint: HOT 1
- Issue with the sampler
- Batch size issue HOT 7
- Shape mismatch diffusion_model HOT 7
- Padding size should be less than the corresponding input dimension HOT 1
- This node will make lora invalid
- Inpaint (Using Model) Node is Not Functioning Properly HOT 2
- Using Fill Mask causes image to be set everywhere in Workflow HOT 1
- Error occurred when executing INPAINT_ApplyFooocusInpaint: Sizes of tensors must match except in dimension 1. Expected size 1 but got size 2 for tensor number 1 in the list. HOT 3
- /comfyui-inpaint-nodes/util.py resize_square cannot handle w/h >= 2 or w/h <= 0.5 image HOT 1
- I have modified this ApplyFocusInpaint to handle video frames
- 我运行不成功,提示下列错误,有人能帮我么?
- 请问下opencv是要安装在哪个目录下?
- fill masked area is actually smaller than the input mask HOT 2
- RuntimeError: PytorchStreamReader failed locating file constants.pkl: file not found
- Doesn't work with impact pack detailer debug HOT 1
- cant load model from 'Load Fooocus Inpaint' node HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from comfyui-inpaint-nodes.