Skip to content

Instantly share code, notes, and snippets.

@G36maid
Created October 9, 2024 15:37
Show Gist options
  • Select an option

  • Save G36maid/99f71db0ae749c5b60bb2b6a95b2ca84 to your computer and use it in GitHub Desktop.

Select an option

Save G36maid/99f71db0ae749c5b60bb2b6a95b2ca84 to your computer and use it in GitHub Desktop.
Traceback (most recent call last):
File "/app/lyrisOnlyModel.py", line 141, in <module>
main()
File "/app/lyrisOnlyModel.py", line 138, in main
traning(lyrisfile, bert_model, tokenizer, model, diffusionModel, title, artist)
File "/app/lyrisOnlyModel.py", line 79, in traning
lyris_vector = BERT(**lyrisinputs).last_hidden_state[:, 0, :]
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1553, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1562, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/transformers/models/bert/modeling_bert.py", line 1078, in forward
embedding_output = self.embeddings(
^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1553, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1562, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/transformers/models/bert/modeling_bert.py", line 211, in forward
inputs_embeds = self.word_embeddings(input_ids)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1553, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1562, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/torch/nn/modules/sparse.py", line 164, in forward
return F.embedding(
^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/torch/nn/functional.py", line 2267, in embedding
return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu! (when checking argument for argument index in method wrapper_CUDA__index_select)
@Panda7122
Copy link
Copy Markdown

slove line 79 issue in training()
add .to(device)
@G36maid thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment