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

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

Open
xllusion-dong opened this issue Apr 23, 2024 · 1 comment

Comments

@xllusion-dong
Copy link

xllusion-dong commented Apr 23, 2024

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 xllusion-dong changed the title RuntimeError: Expected all tensors to be on the same device RuntimeError: Expected all tensors to be on the same device but found at least two devices, cuda:0 and cpu! Apr 23, 2024
@Zakhmaster
Copy link

see #10
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants