torch.cuda.OutOfMemoryError: Allocation on device
ComplyUI in use, torch.cuda.OutOfMemoryError:Allocation on device error.
Python version: 3.11.6
Total VRAM 16380 MB, total RAM 65349 MB
pytorch version: 2.3.0+cu121
Set vram state to: NORMAL_VRAM
Device: cuda:0 NVIDIA GeForce RTX 4060 Ti : cudaMallocAsync
!!! Exception during processing!!! Allocation on device
Traceback (most recent call last):
File "A:\SynologyDrive\ComfyUI-webui\ComfyUI\execution.py", line 151, in recursive_execute
output_data, output_ui = get_output_data(obj, input_data_all)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "A:\SynologyDrive\ComfyUI-webui\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 "A:\SynologyDrive\ComfyUI-webui\ComfyUI\execution.py", line 74, in map_node_over_list
results.append(getattr(obj, func)(**slice_dict(input_data_all, i)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "A:\SynologyDrive\ComfyUI-webui\ComfyUI\custom_nodes\ComfyUI-Impact-Pack\modules\impact\impact_pack.py", line 557, in doit
enhanced_img, cropped_enhanced, cropped_enhanced_alpha, mask, cnet_pil_list = FaceDetailer.enhance_face(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "A:\SynologyDrive\ComfyUI-webui\ComfyUI\custom_nodes\ComfyUI-Impact-Pack\modules\impact\impact_pack.py", line 496, in enhance_face
sam_mask = core.make_sam_mask(sam_model_opt, segs, image, sam_detection_hint, sam_dilation,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "A:\SynologyDrive\ComfyUI-webui\ComfyUI\custom_nodes\ComfyUI-Impact-Pack\modules\impact\core.py", line 694, in make_sam_mask
detected_masks = sam_obj.predict(image, points, plabs, dilated_bbox, threshold)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "A:\SynologyDrive\ComfyUI-webui\ComfyUI\custom_nodes\ComfyUI-Impact-Pack\modules\impact\core.py", line 565, in predict
predictor.set_image(image, "RGB")
File "A:\SynologyDrive\ComfyUI-webui\python_embeded\Lib\site-packages\segment_anything\predictor.py", line 60, in set_image
self.set_torch_image(input_image_torch, image.shape[:2])
File "A:\SynologyDrive\ComfyUI-webui\python_embeded\Lib\site-packages\torch\utils_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "A:\SynologyDrive\ComfyUI-webui\python_embeded\Lib\site-packages\segment_anything\predictor.py", line 89, in set_torch_image
self.features = self.model.image_encoder(input_image)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "A:\SynologyDrive\ComfyUI-webui\python_embeded\Lib\site-packages\torch\nn\modules\module.py", line 1532, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "A:\SynologyDrive\ComfyUI-webui\python_embeded\Lib\site-packages\torch\nn\modules\module.py", line 1541, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "A:\SynologyDrive\ComfyUI-webui\python_embeded\Lib\site-packages\segment_anything\modeling\image_encoder.py", line 112, in forward
x = blk(x)
^^^^^^
File "A:\SynologyDrive\ComfyUI-webui\python_embeded\Lib\site-packages\torch\nn\modules\module.py", line 1532, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "A:\SynologyDrive\ComfyUI-webui\python_embeded\Lib\site-packages\torch\nn\modules\module.py", line 1541, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "A:\SynologyDrive\ComfyUI-webui\python_embeded\Lib\site-packages\segment_anything\modeling\image_encoder.py", line 174, in forward
x = self.attn(x)
^^^^^^^^^^^^
File "A:\SynologyDrive\ComfyUI-webui\python_embeded\Lib\site-packages\torch\nn\modules\module.py", line 1532, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "A:\SynologyDrive\ComfyUI-webui\python_embeded\Lib\site-packages\torch\nn\modules\module.py", line 1541, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "A:\SynologyDrive\ComfyUI-webui\python_embeded\Lib\site-packages\segment_anything\modeling\image_encoder.py", line 234, in forward
attn = add_decomposed_rel_pos(attn, q, self.rel_pos_h, self.rel_pos_w, (H, W), (H, W))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "A:\SynologyDrive\ComfyUI-webui\python_embeded\Lib\site-packages\segment_anything\modeling\image_encoder.py", line 358, in add_decomposed_rel_pos
attn.view(B, q_h, q_w, k_h, k_w) + rel_h[:, :, :, :, None] + rel_w[:, :, :, None, :]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
torch.cuda.OutOfMemoryError: Allocation on device
I'm using the "face detailer" of the "impact pack", and an error occurs on this node.
I used "ultimateSDUpscale" just before.
If you use the corresponding ControlNet model, you will get an error.