city96 / ComfyUI_ExtraModels

Support for miscellaneous image models. Currently supports: DiT, PixArt, HunYuanDiT, MiaoBi, and a few VAEs.
Apache License 2.0
372 stars 34 forks source link

T5TextEncode: Tensor on device cpu is not on the expected device meta! #7

Open jmanhype opened 9 months ago

jmanhype commented 9 months ago

Error occurred when executing T5TextEncode:

Tensor on device cpu is not on the expected device meta!

File "C:\Users\strau\ComfyUI\execution.py", line 154, in recursive_execute output_data, output_ui = get_output_data(obj, input_data_all) File "C:\Users\strau\ComfyUI\execution.py", line 84, in get_output_data return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True) File "C:\Users\strau\ComfyUI\execution.py", line 77, in map_node_over_list results.append(getattr(obj, func)(slice_dict(input_data_all, i))) File "C:\Users\strau\ComfyUI\custom_nodes\ComfyUI_ExtraModels\T5\nodes.py", line 83, in encode cond = T5.encode_from_tokens(tokens) File "C:\Users\strau\ComfyUI\custom_nodes\ComfyUI_ExtraModels\T5\loader.py", line 71, in encode_from_tokens return self.cond_stage_model.encode_token_weights(tokens) File "C:\Users\strau\ComfyUI\custom_nodes\ComfyUI_ExtraModels\T5\t5v11.py", line 97, in encode_token_weights out = self.encode(to_encode) File "C:\Users\strau\ComfyUI\custom_nodes\ComfyUI_ExtraModels\T5\t5v11.py", line 79, in encode return self(tokens) File "C:\Users\strau\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl return self._call_impl(*args, *kwargs) File "C:\Users\strau\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl return forward_call(args, kwargs) File "C:\Users\strau\ComfyUI\custom_nodes\ComfyUI_ExtraModels\T5\t5v11.py", line 72, in forward outputs = self.transformer(input_ids=tokens, attention_mask=attention_mask) File "C:\Users\strau\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl return self._call_impl(*args, kwargs) File "C:\Users\strau\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl return forward_call(*args, *kwargs) File "C:\Users\strau\AppData\Local\Programs\Python\Python310\lib\site-packages\transformers\models\t5\modeling_t5.py", line 1975, in forward encoder_outputs = self.encoder( File "C:\Users\strau\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl return self._call_impl(args, kwargs) File "C:\Users\strau\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl return forward_call(*args, kwargs) File "C:\Users\strau\AppData\Local\Programs\Python\Python310\lib\site-packages\transformers\models\t5\modeling_t5.py", line 1110, in forward layer_outputs = layer_module( File "C:\Users\strau\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl return self._call_impl(*args, *kwargs) File "C:\Users\strau\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl return forward_call(args, kwargs) File "C:\Users\strau\AppData\Local\Programs\Python\Python310\lib\site-packages\transformers\models\t5\modeling_t5.py", line 694, in forward self_attention_outputs = self.layer[0]( File "C:\Users\strau\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl return self._call_impl(*args, kwargs) File "C:\Users\strau\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl return forward_call(*args, *kwargs) File "C:\Users\strau\AppData\Local\Programs\Python\Python310\lib\site-packages\transformers\models\t5\modeling_t5.py", line 600, in forward normed_hidden_states = self.layer_norm(hidden_states) File "C:\Users\strau\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl return self._call_impl(args, kwargs) File "C:\Users\strau\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl return forward_call(*args, kwargs) File "C:\Users\strau\AppData\Local\Programs\Python\Python310\lib\site-packages\transformers\models\t5\modeling_t5.py", line 260, in forward return self.weight hidden_states File "C:\Users\strau\AppData\Local\Programs\Python\Python310\lib\site-packages\torch_prims_common\wrappers.py", line 229, in _fn result = fn(args, kwargs) File "C:\Users\strau\AppData\Local\Programs\Python\Python310\lib\site-packages\torch_prims_common\wrappers.py", line 132, in _fn result = fn(*bound.arguments) File "C:\Users\strau\AppData\Local\Programs\Python\Python310\lib\site-packages\torch_refs__init.py", line 982, in _ref output = prim(a, b) File "C:\Users\strau\AppData\Local\Programs\Python\Python310\lib\site-packages\torch_refs__init__.py", line 1610, in mul return prims.mul(a, b) File "C:\Users\strau\AppData\Local\Programs\Python\Python310\lib\site-packages\torch_ops.py", line 448, in call__ return self._op(args, *kwargs or {}) File "C:\Users\strau\AppData\Local\Programs\Python\Python310\lib\site-packages\torch_prims__init__.py", line 351, in _elementwise_meta utils.check_same_device(args_, allow_cpu_scalar_tensors=True) File "C:\Users\strau\AppData\Local\Programs\Python\Python310\lib\site-packages\torch_prims_common__init__.py", line 654, in check_same_device raise RuntimeError(msg)

Clos

city96 commented 9 months ago

Just a hunch, but I think your transformers or pytorch version might be too old. I can't think of anything in my code that would end up with something on the meta device.

jmanhype commented 9 months ago

So best bet is to use comfy ui portable in a virt env?

On Fri, Jan 12, 2024, 6:05 AM City @.***> wrote:

Just a hunch, but I think your transformers or pytorch version might be too old. I can't think of anything in my code that would end up with something on the meta device.

— Reply to this email directly, view it on GitHub https://github.com/city96/ComfyUI_ExtraModels/issues/7#issuecomment-1889004954, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANMI52AMWGMTXAMSVKNRHCLYOERKBAVCNFSM6AAAAABBXWOOQCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBZGAYDIOJVGQ . You are receiving this because you authored the thread.Message ID: @.***>

city96 commented 9 months ago

You might be able to upgrade those packages in your current env, assuming nothing else you use it for relies explicitly on the older versions.

Can you paste the output for these two commands:

python -m pip show transformers
python -m pip show torch