Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SOLVED] RuntimeError: Input type (torch.FloatTensor) and weight type (PrivateUse1FloatType) should be the same #40

Closed
patientx opened this issue Sep 21, 2023 · 8 comments

Comments

@patientx
Copy link

I was using reactor on sdwebui without any problems and just found out it is also available for comfy , wanted to try it. It works if I don't select a face restore model but if I select either of the two the following error is shown and nothing is produced :
`Error occurred when executing ReActorFaceSwap:

Input type (torch.FloatTensor) and weight type (PrivateUse1FloatType) should be the same or input should be a MKLDNN tensor and weight is a dense tensor

File "D:\ComfyUI\execution.py", line 152, in recursive_execute
output_data, output_ui = get_output_data(obj, input_data_all)
File "D:\ComfyUI\execution.py", line 82, in get_output_data
return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True)
File "D:\ComfyUI\execution.py", line 75, in map_node_over_list
results.append(getattr(obj, func)(**slice_dict(input_data_all, i)))
File "D:\ComfyUI\custom_nodes\comfyui-reactor-node\nodes.py", line 117, in execute
self.face_helper.get_face_landmarks_5(only_center_face=False, resize=640, eye_dist_threshold=5)
File "D:\ComfyUI\custom_nodes\comfyui-reactor-node\facelib\utils\face_restoration_helper.py", line 151, in get_face_landmarks_5
bboxes = self.face_det.detect_faces(input_img)
File "D:\ComfyUI\custom_nodes\comfyui-reactor-node\facelib\detection\retinaface\retinaface.py", line 209, in detect_faces
loc, conf, landmarks, priors = self.__detect_faces(image)
File "D:\ComfyUI\custom_nodes\comfyui-reactor-node\facelib\detection\retinaface\retinaface.py", line 156, in __detect_faces
loc, conf, landmarks = self(inputs)
File "D:\ComfyUI\env\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "D:\ComfyUI\custom_nodes\comfyui-reactor-node\facelib\detection\retinaface\retinaface.py", line 121, in forward
out = self.body(inputs)
File "D:\ComfyUI\env\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "D:\ComfyUI\env\lib\site-packages\torchvision\models_utils.py", line 69, in forward
x = module(x)
File "D:\ComfyUI\env\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "D:\ComfyUI\env\lib\site-packages\torch\nn\modules\conv.py", line 463, in forward
return self._conv_forward(input, self.weight, self.bias)
File "D:\ComfyUI\env\lib\site-packages\torch\nn\modules\conv.py", line 459, in _conv_forward
return F.conv2d(input, weight, bias, self.stride,`

@Gourieff Gourieff added bug Something isn't working ⛔ dependencies conflict labels Sep 22, 2023
@Gourieff
Copy link
Owner

Gourieff commented Sep 22, 2023

Could you please provide pip list, pip show torch and python -V - for ComfyUI\env

@patientx
Copy link
Author

pip list :

(env) D:\ComfyUI>pip list
Package Version


accelerate 0.21.0
aiohttp 3.8.5
aiosignal 1.3.1
albumentations 1.3.1
async-timeout 4.0.2
attrs 23.1.0
boltons 23.0.0
certifi 2023.7.22
charset-normalizer 3.2.0
colorama 0.4.6
coloredlogs 15.0.1
contourpy 1.1.0
cycler 0.11.0
Cython 3.0.0
easydict 1.10
einops 0.6.1
filelock 3.12.2
flatbuffers 23.5.26
fonttools 4.42.1
frozenlist 1.4.0
fsspec 2023.6.0
gitdb 4.0.10
GitPython 3.1.32
huggingface-hub 0.16.4
humanfriendly 10.0
idna 3.4
imageio 2.31.1
insightface 0.7.3
Jinja2 3.1.2
joblib 1.3.2
kiwisolver 1.4.4
lazy_loader 0.3
MarkupSafe 2.1.3
matplotlib 3.7.2
mpmath 1.3.0
multidict 6.0.4
networkx 3.1
numpy 1.25.2
onnx 1.14.0
onnxruntime 1.15.0
opencv-python 4.7.0.72
opencv-python-headless 4.8.0.76
packaging 23.1
Pillow 10.0.0
pip 23.2.1
prettytable 3.8.0
protobuf 4.24.1
psutil 5.9.5
pyparsing 3.0.9
pyreadline3 3.4.1
python-dateutil 2.8.2
PyWavelets 1.4.1
PyYAML 6.0.1
qudida 0.0.4
regex 2023.6.3
requests 2.31.0
safetensors 0.3.1
scikit-image 0.21.0
scikit-learn 1.3.0
scipy 1.11.1
setuptools 65.5.0
six 1.16.0
smmap 5.0.0
sympy 1.12
threadpoolctl 3.2.0
tifffile 2023.8.12
tokenizers 0.13.3
torch 2.0.0
torch-directml 0.2.0.dev230426
torchsde 0.2.5
torchvision 0.15.1
tqdm 4.65.0
trampoline 0.1.2
transformers 4.31.0
typing_extensions 4.7.1
urllib3 2.0.4
wcwidth 0.2.6
yarl 1.9.2

pip show torch ::

(env) D:\ComfyUI>pip show torch
Name: torch
Version: 2.0.0
Summary: Tensors and Dynamic neural networks in Python with strong GPU acceleration
Home-page: https://pytorch.org/
Author: PyTorch Team
Author-email: [email protected]
License: BSD-3
Location: d:\comfyui\env\lib\site-packages
Requires: filelock, jinja2, networkx, sympy, typing-extensions
Required-by: accelerate, torch-directml, torchsde, torchvision

python -V ::
(env) D:\ComfyUI>python -V
Python 3.10.11

@patientx
Copy link
Author

the only extension other than this one is the manager btw.

@Gourieff
Copy link
Owner

Cannot repeat these errors
Everything works fine both in ComfyUI Portable and in A1111
Try to upgrade Torch to version 2.0.1 and Torchvision to 0.15.2

Also you use different versions of one package:
opencv-python 4.7.0.72
opencv-python-headless 4.8.0.76
It's not right and can also cause some conflicts
Only one version of opencv-python must be inside one environment

@patientx
Copy link
Author

patientx commented Sep 25, 2023

updated both torch and torchvision and then made the others same version , still the same error , in the end deleted the venv folder and set up the comfyui (while setting this up I found out the reason torch and torchvision's version numbers, those are installed by "pip install torch-directml") , then setup this extension , installed its requirements via install.bat inside the folder, then.... this error : "This ORT build has ['TensorrtExecutionProvider', 'CUDAExecutionProvider', 'CPUExecutionProvider'] enabled." which I solved by uninstalling downgrading "onnxruntime-1.16.0" (which comfy installs by default) to "onnxruntime-1.15.1" ..... Annnnd ...

"RuntimeError: Input type (torch.FloatTensor) and weight type (PrivateUse1FloatType) should be the same or input should be a MKLDNN tensor and weight is a dense tensor"

same error as before , and while re updating torch to 2.0.1 this bit here:

"torch-directml 0.2.0.dev230426 requires torch==2.0.0, but you have torch 2.0.1 which is incompatible.
torch-directml 0.2.0.dev230426 requires torchvision==0.15.1, but you have torchvision 0.15.2 which is incompatible."

so if I want to use directml with my amd gpu with comfy , it doesnt work with the extension.

To be clear it works if I don't use a face restore model , just basic swapping. This also works in other roop extensions too. ALSO everything including face restore function works beautifully with a1111.

@Gourieff
Copy link
Owner

Yeah, it seems to be some incompatibility with torch-directml library
The way to solve is to use without it
Restoration models are very lightweight, so I don't think that there will be a very noticeable boost with directml

@liaosu0755
Copy link

same.

Error occurred when executing ReActorFaceSwap:

Ran out of input

File "L:\ComfyUI_windows_portable\ComfyUI\execution.py", line 152, in recursive_execute
output_data, output_ui = get_output_data(obj, input_data_all)
File "L:\ComfyUI_windows_portable\ComfyUI\execution.py", line 82, in get_output_data
return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True)
File "L:\ComfyUI_windows_portable\ComfyUI\execution.py", line 75, in map_node_over_list
results.append(getattr(obj, func)(**slice_dict(input_data_all, i)))
File "L:\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui-reactor-node\nodes.py", line 100, in execute
self.face_helper = FaceRestoreHelper(1, face_size=512, crop_ratio=(1, 1), det_model=facedetection, save_ext='png', use_parse=True, device=device)
File "L:\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui-reactor-node\facelib\utils\face_restoration_helper.py", line 105, in init
self.face_det = init_detection_model(det_model, half=False, device=self.device)
File "L:\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui-reactor-node\facelib\detection_init_.py", line 17, in init_detection_model
model = init_retinaface_model(model_name, half, device)
File "L:\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui-reactor-node\facelib\detection_init_.py", line 37, in init_retinaface_model
load_net = torch.load(model_path, map_location=lambda storage, loc: storage)
File "L:\ComfyUI_windows_portable\python_embeded\lib\site-packages\torch\serialization.py", line 815, in load
return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
File "L:\ComfyUI_windows_portable\python_embeded\lib\site-packages\torch\serialization.py", line 1043, in _legacy_load
result = unpickler.load()

@patientx
Copy link
Author

patientx commented Oct 15, 2023

Finally solved this by deleting torch and torchvision from the requirements , This way it is using torch 2.0.0 and torchvision 0.15.1 from the default installed versions of comfyui and codeformer etc is working correctly.

@Gourieff Gourieff changed the title Error when any face restore model selected (codeformer or gfpgan) [SOLVED] RuntimeError: Input type (torch.FloatTensor) and weight type (PrivateUse1FloatType) should be the same Oct 16, 2023
@Gourieff Gourieff added ✔ solved and removed bug Something isn't working labels Oct 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants