M3VSNet
M3VSNet copied to clipboard
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [1, 3, 3]] is at version 17; expected version 13 instead. Hint: enable anomaly detection to find the operation that failed to compute its gradient, with torch.autograd.set_detect_anomaly(True).
Maybe the codes need to be changed with different variables
I could run it successfully. Do you delete some code such as ".clone()"???
I could run it successfully. Do you delete some code such as ".clone()"???
I don't edit the codes. But I'm wondering if it is relevant to the environment because I don't specifically check my environment to match the required environment.
@agenthong You need to check your environment or google this error.
@agenthong You need to check your environment or google this error.
@whubaichuan Thanks. By the way can you share the requests list hence we can directly install the envireonment.
@agenthong Here
@agenthong Here
Thanks for replying. I can't directly use ' pip install -r ' to install env.
Can you share a necessary env list in valid format?
Update:I change the pytorch version to match the requirements env then this problem is solved.
@agenthong Congratulation!
Update:I change the pytorch version to match the requirements env then this problem is solved.
I met the same error, could you tell me which version of pytorch to solve this problem? Thanks a lot!
@fox16789 I use pytorch 1.0.1
Update:I change the pytorch version to match the requirements env then this problem is solved.
I met the same error, could you tell me which version of pytorch to solve this problem? Thanks a lot!
Actually I didn't solve this question even if I use the corresponding pytorch version. I'm checking the code to figure out if I can fix it.
The error place is mvsnet.py:329
K_xyz_src = torch.matmul(intrinsics_src, xyz_src) #B*3*20480
the intrinsics_src seems to be changed in later
I change the code to
intrinsics_src_ = intrinsics_src
K_xyz_src = torch.matmul(intrinsics_src_, xyz_src) #B*3*20480
it works but i don't know if it's right.
The error place is mvsnet.py:329
K_xyz_src = torch.matmul(intrinsics_src, xyz_src) #B*3*20480
the intrinsics_src seems to be changed in later I change the code tointrinsics_src_ = intrinsics_src K_xyz_src = torch.matmul(intrinsics_src_, xyz_src) #B*3*20480
it works but i don't know if it's righ
I tried this but it didn't work.
The error place is mvsnet.py:329
K_xyz_src = torch.matmul(intrinsics_src, xyz_src) #B*3*20480
the intrinsics_src seems to be changed in later I change the code tointrinsics_src_ = intrinsics_src K_xyz_src = torch.matmul(intrinsics_src_, xyz_src) #B*3*20480
it works but i don't know if it's righ
I tried this but it didn't work.
I also change all loss+= to loss = loss + in mvsnet.py. Maybe you can try.
I also encountered the same problem. (In the same environment.) I not only tried using a=a+b instead of a+=b, but also modified the code like this. intrinsics_src_ = intrinsics_src K_xyz_src = torch.matmul(intrinsics_src_, xyz_src) #B320480
It's still not working.
The error message shows as follows:
sys:1: RuntimeWarning: Traceback of forward call that caused the error:
File "train.py", line 398, in
Traceback (most recent call last):
File "train.py", line 398, in
I also encountered the same problem. (In the same environment.) I not only tried using a=a+b instead of a+=b, but also modified the code like this. intrinsics_src_ = intrinsics_src K_xyz_src = torch.matmul(intrinsics_src_, xyz_src) #B_3_20480
It's still not working.
The error message shows as follows:
sys:1: RuntimeWarning: Traceback of forward call that caused the error: File "train.py", line 398, in train() File "train.py", line 155, in train loss,scalar_outputs,image_outputs = train_sample(sample, detailed_summary=do_summary) File "train.py", line 271, in train_sample loss,loss_s,loss_photo,loss_ssim,mask_calculate,mask_num,loss_perceptual,loss_normal,normal_by_depth,error_depth_by_normal,depth_by_normal=model_loss(depth_est,intrinsics,extrinsics,sample_cuda["imgs"],mask_photometric,outputs_feature) File "/home/jojo/Documents/github/M3VSNet/models/mvsnet.py", line 1024, in mvsnet_loss x_src_perceptual,y_src_perceptual=project_with_depth(depth_est_perceptual, ref_intrinsics_perceptual, ref_extrinsics, src_intrinsics_perceptual, src_extrinsics[i]) File "/home/jojo/Documents/github/M3VSNet/models/mvsnet.py", line 320, in project_with_depth K_xyz_src = torch.matmul(intrinsics_src, xyz_src) #B_3_20480
Traceback (most recent call last): File "train.py", line 398, in train() File "train.py", line 155, in train loss,scalar_outputs,image_outputs = train_sample(sample, detailed_summary=do_summary) File "train.py", line 273, in train_sample loss.backward() File "/home/jojo/anaconda3/envs/m3vsnet/lib/python3.6/site-packages/torch/tensor.py", line 102, in backward torch.autograd.backward(self, gradient, retain_graph, create_graph) File "/home/jojo/anaconda3/envs/m3vsnet/lib/python3.6/site-packages/torch/autograd/init.py", line 90, in backward allow_unreachable=True) # allow_unreachable flag RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation
The problem has been solved on my side, by changing the code like this: K_xyz_src = torch.matmul(intrinsics_src.clone(), xyz_src.clone())