본문으로 바로가기

모델을 변경하면서 실험을 할 때 "gradient computation has been modified by an inplace operation"같은 error만큼 답이 안나오는 상황이 흔치 않다.

 

어떤 경우는 detach()로 해경하는 경우도 있었지만 이번 경우는 "nn.parallel.DistributedDataParallel"을 사용하면서 생겼다.

 

model = nn.parallel.DistributedDataParallel$($model, device_ids=[local_rank], broadcast_buffers=True, find_unused_parameters=False$)$

같은 상황에서 broadcast_buffers option을 True에서 False로 변경했을 때 해결됐다.

 

https://github.com/pytorch/pytorch/issues/62474 https://pytorch.org/docs/stable/generated/torch.nn.parallel.DistributedDataParallel.html

 

Distributed: RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torc

🐛 Bug when using distributed with pretrained model, backprop seems to error out due to inplace modification. To Reproduce I have converted a repo: https://github.com/talreiss/Mean-Shifted-Anomaly-D...

github.com

 

 


MisoYuri's Deck
블로그 이미지 MisoYuri 님의 블로그
VISITOR 오늘 / 전체