comfyui_segment_anything icon indicating copy to clipboard operation
comfyui_segment_anything copied to clipboard

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

Open xllusion-dong opened this issue 10 months ago • 1 comments

the full error output like following

Loads SAM model: E:\DEV\ComfyUI_windows_portable\ComfyUI\models\sams\sam_vit_h_4b8939.pth (device:AUTO)
final text_encoder_type: bert-base-uncased
!!! Exception during processing !!!
Traceback (most recent call last):
  File "E:\DEV\ComfyUI_windows_portable\ComfyUI\execution.py", line 151, in recursive_execute
    output_data, output_ui = get_output_data(obj, input_data_all)
  File "E:\DEV\ComfyUI_windows_portable\ComfyUI\execution.py", line 81, in get_output_data
    return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True)
  File "E:\DEV\ComfyUI_windows_portable\ComfyUI\execution.py", line 74, in map_node_over_list
    results.append(getattr(obj, func)(**slice_dict(input_data_all, i)))
  File "E:\DEV\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui_segment_anything\node.py", line 325, in main
    (images, masks) = sam_segment(
  File "E:\DEV\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui_segment_anything\node.py", line 247, in sam_segment
    masks, _, _ = predictor.predict_torch(
  File "E:\DEV\ComfyUI_windows_portable\python_embeded\lib\site-packages\torch\utils\_contextlib.py", line 115, in decorate_context
    return func(*args, **kwargs)
  File "E:\DEV\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui_segment_anything\sam_hq\predictor.py", line 114, in predict_torch
    sparse_embeddings, dense_embeddings = self.model.prompt_encoder(
  File "E:\DEV\ComfyUI_windows_portable\python_embeded\lib\site-packages\torch\nn\modules\module.py", line 1511, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "E:\DEV\ComfyUI_windows_portable\python_embeded\lib\site-packages\torch\nn\modules\module.py", line 1520, in _call_impl
    return forward_call(*args, **kwargs)
  File "E:\DEV\ComfyUI_windows_portable\python_embeded\lib\site-packages\segment_anything\modeling\prompt_encoder.py", line 158, in forward
    box_embeddings = self._embed_boxes(boxes)
  File "E:\DEV\ComfyUI_windows_portable\python_embeded\lib\site-packages\segment_anything\modeling\prompt_encoder.py", line 97, in _embed_boxes
    corner_embedding = self.pe_layer.forward_with_coords(coords, self.input_image_size)
  File "E:\DEV\ComfyUI_windows_portable\python_embeded\lib\site-packages\segment_anything\modeling\prompt_encoder.py", line 214, in forward_with_coords
    return self._pe_encoding(coords.to(torch.float))  # B x N x C
  File "E:\DEV\ComfyUI_windows_portable\python_embeded\lib\site-packages\segment_anything\modeling\prompt_encoder.py", line 189, in _pe_encoding
    coords = coords @ self.positional_encoding_gaussian_matrix
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu! (when checking argument for argument mat2 in method `wrapper_CUDA_mm)

Any suggestion for this?

xllusion-dong avatar Apr 23 '24 07:04 xllusion-dong

see #10 image

Zakhmaster avatar May 23 '24 20:05 Zakhmaster