ComfyUI icon indicating copy to clipboard operation
ComfyUI copied to clipboard

cannot access local variable 'act_fn' where it is not associated with a value

Open rtberbary opened this issue 10 months ago • 7 comments

Expected Behavior

getting this when trying the FRAME PACK MODEL INSTEAD OF IT RUNNING

Actual Behavior

Image

Steps to Reproduce

using the new frame pack model

Debug Logs

!!! Exception during processing !!! cannot access local variable 'act_fn' where it is not associated with a value
Traceback (most recent call last):
  File "D:\comfyuistudio\V200\App\ComfyUI\execution.py", line 345, 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 "D:\comfyuistudio\V200\App\ComfyUI\execution.py", line 220, 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 "D:\comfyuistudio\V200\App\ComfyUI\execution.py", line 192, in _map_node_over_list
    process_inputs(input_dict, i)
  File "D:\comfyuistudio\V200\App\ComfyUI\execution.py", line 181, in process_inputs
    results.append(getattr(obj, func)(**inputs))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\comfyuistudio\V200\App\ComfyUI\custom_nodes\ComfyUI-FramePackWrapper\nodes.py", line 200, in loadmodel
    transformer = HunyuanVideoTransformer3DModelPacked(**config)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\comfyuistudio\V200\App\python_embeded\Lib\site-packages\diffusers\configuration_utils.py", line 665, in inner_init
    init(self, *args, **init_kwargs)
  File "D:\comfyuistudio\V200\App\ComfyUI\custom_nodes\ComfyUI-FramePackWrapper\diffusers_helper\models\hunyuan_video_packed.py", line 739, in __init__
    self.context_embedder = HunyuanVideoTokenRefiner(
                            ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\comfyuistudio\V200\App\ComfyUI\custom_nodes\ComfyUI-FramePackWrapper\diffusers_helper\models\hunyuan_video_packed.py", line 373, in __init__
    self.token_refiner = HunyuanVideoIndividualTokenRefiner(
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\comfyuistudio\V200\App\ComfyUI\custom_nodes\ComfyUI-FramePackWrapper\diffusers_helper\models\hunyuan_video_packed.py", line 320, in __init__
    [
  File "D:\comfyuistudio\V200\App\ComfyUI\custom_nodes\ComfyUI-FramePackWrapper\diffusers_helper\models\hunyuan_video_packed.py", line 321, in <listcomp>
    HunyuanVideoIndividualTokenRefinerBlock(
  File "D:\comfyuistudio\V200\App\ComfyUI\custom_nodes\ComfyUI-FramePackWrapper\diffusers_helper\models\hunyuan_video_packed.py", line 280, in __init__
    self.ff = FeedForward(hidden_size, mult=mlp_width_ratio, activation_fn="linear-silu", dropout=mlp_drop_rate)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\comfyuistudio\V200\App\python_embeded\Lib\site-packages\diffusers\models\attention.py", line 1228, in __init__
    self.net.append(act_fn)
                    ^^^^^^
UnboundLocalError: cannot access local variable 'act_fn' where it is not associated with a value

Other

No response

rtberbary avatar Apr 19 '25 23:04 rtberbary

Getting the same issue, using the example FramePack workflow.

iam-face avatar Apr 20 '25 02:04 iam-face

Same here

yotraxxx avatar Apr 20 '25 11:04 yotraxxx

I got around this by installing a newer version (0.33.1) of the diffusers library: https://github.com/kijai/ComfyUI-FramePackWrapper/blob/main/requirements.txt#L2

This is because this line https://github.com/kijai/ComfyUI-FramePackWrapper/blob/main/diffusers_helper/models/hunyuan_video_packed.py#L280 calls diffusers with 'activation_fn="linear-silu" that is not present here in the older versions: https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/attention.py#L1231

llindqvi avatar Apr 20 '25 15:04 llindqvi

0.33.1 not work.

liangwei191 avatar Apr 21 '25 05:04 liangwei191

What Python version are you using?!

I changed to 3.10 and the error disappeared. It occurs with 3.11.

KHR-TEST-ACCOUNT avatar Apr 22 '25 04:04 KHR-TEST-ACCOUNT

What Python version are you using?!

I changed to 3.10and the error disappeared. It occurs with 3.11.

This error is with Python 3.10.9 too: UnboundLocalError: local variable 'act_fn' referenced before assignment

nyukers avatar Apr 24 '25 11:04 nyukers

It was running om python 3.12.9 for me, but I was trying to upgrade comfy version and front end versions today on some containers and now I'm getting this error as well.

Psylenceo avatar Apr 27 '25 05:04 Psylenceo

The workflow does not work. It will stuck at the first node (Down)load FramePack Model or in Load FramePack Model

The error will appear on Comfy cannot access local variable 'act_fn' where it is not associated with a value

clemarjonlaguardia avatar Apr 28 '25 10:04 clemarjonlaguardia

Full update ComfyUI and FramePack solved this error for me! Python 3.10.9

nyukers avatar Apr 29 '25 09:04 nyukers

What Python version are you using?!

I changed to 3.10 and the error disappeared. It occurs with 3.11.

I also encountered the same problem. Whether it was replacing the model or updating the diffusers, (the Python version was 3.11.9, and the diffusers version was 0.35.1)

Image

benwu9876 avatar Aug 30 '25 10:08 benwu9876

updating solved the problem.

parthwagh9999 avatar Jan 10 '26 08:01 parthwagh9999