Skip to content

ImportError: cannot import name 'clear_device_cache' from 'accelerate.utils.memory' #177

Description

@bird19840926

各种依赖版本都查了,也满足requirements的要求,请大佬帮忙看看到底是啥原因:
accelerate 0.31.0

numpy 1.26.4

torch 2.8.0+cu129
torchvision: 0.23.0+cu129
torchaudio: 2.8.0+cu129

huggingface-hub 0.34.4
safetensors 0.6.2
packaging 25.0
psutil 7.0.0
pyyaml 6.0.2
bitsandbytes 0.47.0
sentencepiece 0.2.0
pillow 11.0.0
bitsandbytes 0.47.0
peft 0.17.1

报错信息为:
got prompt
2025-09-06T00:01:18.951627 - H:\ComfyUI-aki-v1.4\models\clip\siglip-so400m-patch14-3842025-09-06T00:01:18.952620 -
2025-09-06T00:01:20.031858 - Loading VLM's custom vision model2025-09-06T00:01:20.031858 -
2025-09-06T00:01:21.036049 - Requested to load SiglipVisionTransformer
2025-09-06T00:01:21.375453 - loaded completely 9.5367431640625e+25 809.1729736328125 True
2025-09-06T00:01:21.623549 - Requested to load ImageAdapter
2025-09-06T00:01:21.634124 - loaded completely 9.5367431640625e+25 41.0390625 True
2025-09-06T00:01:21.671338 - Loading tokenizer2025-09-06T00:01:21.671338 -
2025-09-06T00:01:22.055693 - Loading LLM: unsloth/Meta-Llama-3.1-8B-Instruct-bnb-4bit2025-09-06T00:01:22.056690 -
2025-09-06T00:01:22.056690 - H:\ComfyUI-aki-v1.4\models\LLM\Meta-Llama-3.1-8B-Instruct-bnb-4bit2025-09-06T00:01:22.056690 -
2025-09-06T00:01:22.057717 - Successfully modified 'base_model_name_or_path' value in 'H:\ComfyUI-aki-v1.4\models\Joy_caption_two\text_model\adapter_config.json'.2025-09-06T00:01:22.057717 -
2025-09-06T00:01:22.372501 - Exception in thread 2025-09-06T00:01:22.372501 - Thread-16 (_readerthread)2025-09-06T00:01:22.372501 - :
2025-09-06T00:01:22.372501 - Traceback (most recent call last):
2025-09-06T00:01:22.372501 - File "H:\ComfyUI-aki-v1.4\python\lib\threading.py", line 1016, in _bootstrap_inner
2025-09-06T00:01:22.372501 - 2025-09-06T00:01:22.372501 - self.run()2025-09-06T00:01:22.372501 -
2025-09-06T00:01:22.372501 - File "<enhanced_experience vendors.sentry_sdk.integrations.threading>", line 99, in run
2025-09-06T00:01:22.374493 - File "<enhanced_experience vendors.sentry_sdk.integrations.threading>", line 94, in _run_old_run_func
2025-09-06T00:01:22.377438 - File "<enhanced_experience vendors.sentry_sdk.utils>", line 1649, in reraise
2025-09-06T00:01:22.380428 - File "<enhanced_experience vendors.sentry_sdk.integrations.threading>", line 92, in _run_old_run_func
2025-09-06T00:01:22.382967 - File "H:\ComfyUI-aki-v1.4\python\lib\threading.py", line 953, in run
2025-09-06T00:01:22.382967 - 2025-09-06T00:01:22.382967 - self._target(*self._args, **self._kwargs)2025-09-06T00:01:22.382967 -
2025-09-06T00:01:22.382967 - File "H:\ComfyUI-aki-v1.4\python\lib\subprocess.py", line 1515, in _readerthread
2025-09-06T00:01:22.383964 - 2025-09-06T00:01:22.383964 - buffer.append(fh.read())2025-09-06T00:01:22.383964 -
2025-09-06T00:01:22.383964 - File "H:\ComfyUI-aki-v1.4\python\lib\codecs.py", line 322, in decode
2025-09-06T00:01:22.383964 - 2025-09-06T00:01:22.383964 - (result, consumed) = self._buffer_decode(data, self.errors, final)2025-09-06T00:01:22.383964 -
2025-09-06T00:01:22.383964 - UnicodeDecodeError2025-09-06T00:01:22.383964 - : 2025-09-06T00:01:22.383964 - 'utf-8' codec can't decode byte 0xb2 in position 6: invalid start byte2025-09-06T00:01:22.383964 -
2025-09-06T00:01:26.146470 - !!! Exception during processing !!! cannot import name 'clear_device_cache' from 'accelerate.utils.memory' (H:\ComfyUI-aki-v1.4\python\lib\site-packages\accelerate\utils\memory.py)
2025-09-06T00:01:26.151000 - Traceback (most recent call last):
File "H:\ComfyUI-aki-v1.4\execution.py", line 327, in execute
output_data, output_ui, has_subgraph = get_output_data(obj, input_data_all, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb)
File "H:\ComfyUI-aki-v1.4\execution.py", line 202, in get_output_data
return_values = _map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb)
File "H:\ComfyUI-aki-v1.4\execution.py", line 174, in map_node_over_list
process_inputs(input_dict, i)
File "H:\ComfyUI-aki-v1.4\execution.py", line 163, in process_inputs
results.append(getattr(obj, func)(**inputs))
File "H:\ComfyUI-aki-v1.4\custom_nodes\ComfyUI_SLK_joy_caption_two\joy_caption_two_node.py", line 383, in generate
text_model = joy_two_pipeline.llm.load_llm_model()
File "H:\ComfyUI-aki-v1.4\custom_nodes\ComfyUI_SLK_joy_caption_two\joy_caption_two_node.py", line 177, in load_llm_model
text_model = AutoModelForCausalLM.from_pretrained(text_model_path,
File "H:\ComfyUI-aki-v1.4\python\lib\site-packages\transformers\models\auto\auto_factory.py", line 564, in from_pretrained
return model_class.from_pretrained(
File "H:\ComfyUI-aki-v1.4\python\lib\site-packages\transformers\modeling_utils.py", line 262, in wrapper
return func(*args, **kwargs)
File "H:\ComfyUI-aki-v1.4\python\lib\site-packages\transformers\modeling_utils.py", line 4404, in from_pretrained
model.load_adapter(
File "H:\ComfyUI-aki-v1.4\python\lib\site-packages\transformers\integrations\peft.py", line 166, in load_adapter
from peft import PeftConfig, inject_adapter_in_model, load_peft_weights
File "H:\ComfyUI-aki-v1.4\python\lib\site-packages\peft_init
.py", line 17, in
from .auto import (
File "H:\ComfyUI-aki-v1.4\python\lib\site-packages\peft\auto.py", line 31, in
from .config import PeftConfig
File "H:\ComfyUI-aki-v1.4\python\lib\site-packages\peft\config.py", line 24, in
from .utils import CONFIG_NAME, PeftType, TaskType
File "H:\ComfyUI-aki-v1.4\python\lib\site-packages\peft\utils_init
.py", line 16, in
from .loftq_utils import replace_lora_weights_loftq
File "H:\ComfyUI-aki-v1.4\python\lib\site-packages\peft\utils\loftq_utils.py", line 25, in
from accelerate.utils.memory import clear_device_cache
ImportError: cannot import name 'clear_device_cache' from 'accelerate.utils.memory' (H:\ComfyUI-aki-v1.4\python\lib\site-packages\accelerate\utils\memory.py)

2025-09-06T00:01:26.152993 - Prompt executed in 7.22 seconds

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions