LucianoCirino/efficiency-nodes-comfyui

Error Occurred During KSampler (Efficient) Execution 'NoneType' object has no attribute 'cpu

suishiyu opened this issue · 18 comments

Seems related to #204 - the erroring code didn't seem to exist before this PR. Le sigh.

Edit: I've tried replacing all the efficiency nodes in my workflow just in case, and deleting all pycache directories just to be thorough, and the error still occurs. Guess I'll just factor efficiency nodes out of my workflow and live without it.

There is a change in how the encoding work! For some reason, it always return 'l' in tokenized and was not properly handled so it always return None. Here is my quick hack to let me use SD1.5 eff. loader for the time being.

In py/bnk_adv_encode.py change advance_encode to the following code (well, only the if 'l' in tokenized... block):

def advanced_encode(clip, text, token_normalization, weight_interpretation, w_max=1.0, clip_balance=.5, apply_to_pooled=True):
    tokenized = clip.tokenize(text, return_word_ids=True)
    if isinstance(tokenized, dict):
        embs_l = None
        embs_g = None
        pooled = None
        if 'l' in tokenized:
            if isinstance(clip.cond_stage_model, SDXLClipModel):
                embs_l, _ = advanced_encode_from_tokens(tokenized['l'], 
                                                    token_normalization, 
                                                    weight_interpretation, 
                                                    lambda x: encode_token_weights(clip, x, encode_token_weights_l),
                                                    w_max=w_max, 
                                                    return_pooled=False)
            else:
                return advanced_encode_from_tokens(tokenized['l'], 
                                                    token_normalization, 
                                                    weight_interpretation, 
                                                    lambda x: encode_token_weights(clip, x, encode_token_weights_l),
                                                    w_max=w_max)
        if 'g' in tokenized:
            embs_g, pooled = advanced_encode_from_tokens(tokenized['g'], 
                                                         token_normalization, 
                                                         weight_interpretation,
                                                         lambda x: encode_token_weights(clip, x, encode_token_weights_g),
                                                         w_max=w_max, 
                                                         return_pooled=True,
                                                         apply_to_pooled=apply_to_pooled)
        return prepareXL(embs_l, embs_g, pooled, clip_balance)
    else:
        return advanced_encode_from_tokens(tokenized,
                                           token_normalization,
                                           weight_interpretation,
                                           lambda x: (clip.encode_from_tokens(x), None),
                                           w_max=w_max)

yea i just ran into this a well, ill test the hack but hopefully something in the main branch can get pushed!

edit:
This code fixed my issue fyi..

Thank you so much. The codefix helped

Having the same issue after latest update. Luckily, I have a non updated install that still works for my workflow. Will try this fix as well.
Edit: Yep; fixed. I did have to delete the files in the efficiency nodes/py/pycache directory though. I just replaced the entire block with this one here.

I can confirm that this not only a Efficiency Node issue only, Using TTN Piple Loader also give 'NoneType' object has no attribute errors. And just for SD1.5

This is because of ComfyUI update. I just rolled back to a backup branch in comfy and EfficiencyNode works again. (But IPAdapterPlus broke... sigh)

Updated all nodes and Comfy today... all efficiency nodes seem broke with that error and others. Using old fashioned loaders and ksamplers worksaround for me. Note to self: BACKUP BEFORE UPDATING next time 😁
UPDATE: I've gone back to using the vanilla nodes, as several other issues I was having (that I thought was Comfy) have been fixed by using vanilla checkpoint loader and ksampler! Oh well, I do like the extra spaghetti anyway.

RigzTD commented

Yeah same here when I updated and everything went kaboom, had this happen a few days ago before this was flagged thinking I broke something in the update, was able to restore a backup thankfully and wanted to try again today to see if it was fixed but the exact same thing happened again. The code fix above did the trick to solve it temporarily till it gets fixed officially. Glad at least its not just me running into this lol like everyone else is saying ALWAYS BACKUP BEFORE AN UPDATE!!!

Noob here with same issue , worked fine till yesterday :( i've been replacing all samplers on workflows by effi ones :/ ... I'll try the hack fix :)

Edit: new code worked!! thanks so much :D ... My Backup did not have the custom nodes ... :D

@MisterAoD codefix worked !!! thanks

@MisterAoD Code worked thank you. Greatly appreciate it!!

Any updates to moving this to dev branch, out of the 10 or so here posting about the issue prob 100's are having it and not using the nodes anymore :/ .. also I think Comfy Devs need to figure out good sort of unit testing , maybe we as a group create a few templates with the Efficient pack and then before pushing out changes they could be run as a test to see what breaks.. anyhow just some thoughts.. cheers and thank you for taking the time to create this!

@MisterAoD

In py/bnk_adv_encode.py change advance_encode to the following code (well, only the if 'l' in tokenized... block):

Thanks for the hack.

It took me two tries before I realised I had to instead search for advanced_encode :)

Also thanks @suishiyu for a good issue title so I could find it easily!

I have updated into my fork and updating any issues here in my forked repo
https://github.com/jags111/efficiency-nodes-comfyui
please update and inform if any more issues. Thanks

I have updated into my fork and updating any issues here in my forked repo https://github.com/jags111/efficiency-nodes-comfyui please update and inform if any more issues. Thanks

your fork worked for me... thanks for putting this out there.