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

one of the variables needed for gradient computation has been modified by an inplace operation #6

Open
TTzhangheng opened this issue Jul 6, 2023 · 7 comments

Comments

@TTzhangheng
Copy link

RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.LongTensor [4, 90]] is at version 1; expected version 0 instead. Hint: why?

@Junyiliu0
Copy link

Same question.Did you solve it?

@Junyiliu0
Copy link

I have solved it. The main problem is in the loss_icr. Just change the bill.py in line 163 to
text_encoder_input_ids = text.input_ids.clone()
text_output = self.text_encoder(text_encoder_input_ids, attention_mask=text.attention_mask,
return_dict=True, mode='text')
Maybe the problem is the input_ids of the text, because the tensor shape is [8,90](my batch_size = 8).

@Paarth002
Copy link

@mlii0117, I am still getting this error 'RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation'. Please suggest how to solve this error.

@confesion
Copy link

I have solved it. The main problem is in the loss_icr. Just change the bill.py in line 163 to text_encoder_input_ids = text.input_ids.clone() text_output = self.text_encoder(text_encoder_input_ids, attention_mask=text.attention_mask, return_dict=True, mode='text') Maybe the problem is the input_ids of the text, because the tensor shape is [8,90](my batch_size = 8).

Yeah,it is blip.py instead of bill.py.

@kongkong935
Copy link

@confesion Hello, I have also encountered this problem. According to your method, it did not solve it. Can you explain it in more detail

@kongkong935
Copy link

@Paarth002 I have also encountered this problem and would like to ask if you have solved it? Can you help me

@kongkong935
Copy link

@TTzhangheng I have also encountered this problem and would like to ask if you have solved it? Can you help me

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