Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid tensor shape #211

Closed
peregilk opened this issue Oct 22, 2022 · 8 comments
Closed

Invalid tensor shape #211

peregilk opened this issue Oct 22, 2022 · 8 comments

Comments

@peregilk
Copy link
Contributor

I keep getting the following error at the end of the first epoch:
"RuntimeError: Input tensor at index 1 has invalid shape [22, 44], but expected [22, 46]". This happens on a custom dataset. However, the dataset is thoroughly cleaned and should be valid.

The error happens in: comm.py, line 231

Any idea what might be causing this?

@peregilk
Copy link
Contributor Author

Deleting the last line in the dataset actually fixed the error in my case.

@epiphany711
Copy link

Do you know the reason of this problem? I met the similar mistake, and I don't know how to fix it. The dataset I used was wiki1m_for_simcse.txt

@peregilk
Copy link
Contributor Author

no. I did not dig into this. I started debugging this, and just wanted to see if the shape of the vector changed if the dataset size changed. Would give me a hint about what was wrong. Then it just solved the issue. Seems like the last batch is filled incorrectly. Most likely trivial. I am new to SimCSE. Someone knowing the code could fix this easier.

@haoliutj
Copy link

haoliutj commented Nov 3, 2022

I have the same issue, deleting the last line does not fix my error. Wondering if anyone has better solutions?

"comm.py", line 235, in gather
return torch._C._gather(tensors, dim, destination)
RuntimeError: Input tensor at index 3 has invalid shape [32, 32], but expected [32, 34]"

@Dicer-Zz
Copy link

Dicer-Zz commented Nov 3, 2022

I meet the same issue for my custom dataset. Can anyone give some suggestion?

@Dicer-Zz
Copy link

Dicer-Zz commented Nov 3, 2022

I found the issue has been solved in #148 . In my case, using only single GPU is working in the unsupervised setting.

@haoliutj
Copy link

haoliutj commented Nov 4, 2022

I solved by running the scripts with multiple GPU. the issue is that I was running the script for single gpu on 4 gpu cards that cause the shape errors. I

@gaotianyu1350
Copy link
Member

Thanks @haoliutj @Dicer-Zz for answering this! This is likely caused by running the single gpu script on multiple GPUs. Please use the corresponding script for different number of GPUs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants