-
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation
Problem DDP를 사용하여 훈련 중 “RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation”와 같은 런타임 에러가 발생했다. 이전 싱글 GPU로 훈련을 진행할 때도 같은 에러가 나온적이 있어 대략적으로 파이토치의 autograd의 그레프 문제라는 것을 알고 있었고 clone과 detach를 해주는 등 예상가는 변수에 조치를 취해줬지만 해결이되지 않았다. 이에대한 파이토치 그룹 커뮤니티가 활발하게 활성화 돼 있는데, 이를 참고하여 해결하였다. Runtime e... Read More
-
nn.DataParallel gets stuck
Problem Multi GPU를 사용하기 위해 파이토치 nn.DataParallel()을 사용하였지만, 명시한 GPU가 100% 풀 로드하고 있음에도 Optimizer.step()에서 다음으로 넘어가지 않는 현상이 발생하였다. 최근까지 문제를 해결하지 못했지만, pytorch discuss에 비슷한 사례와 해결책을 찾을 수 있었다. Although i used Pytorch nn.DataParallel() for use Multi GPU, Even though the specified GPU is fully loaded at 100%, a phenomenon occurred where Optimizer.... Read More
-
PyTorch DISTRIBUTED COMMUNICATION PACKAGE - TORCH.DISTRIBUTED
PyTorch - torch.distributed NOTE Please refer to PyTorch Distributed Overview for a brief introduction to all features related to distributed training. Read More
-
PyTorch exp()
PyTorch - torch.exp[1] torch.exp(torch.tensor([1, 2, 3], [4, 5, 6])) # tensor([e^1, e^2, e^3], [e^4, e^5, e^6]) explain Returns a new tensor with the exponential of the elements of the input tensor input. 입력 텐서인 input의 각 요소를 자연 상수를 밑으로 하는 exponential(지수)로서 변환합니다. \[y_{i} = e^{x_{i}}\] Parameters input: torch.Ten... Read More
-
PyTorch div()
PyTorch - torch.div[1] x = torch.tensor([ 0.3810, 1.2774, -0.2972, -0.3719, 0.4637]) torch.div(x, 0.5) # tensor([ 0.7620, 2.5548, -0.5944, -0.7438, 0.9274]) a = torch.tensor([[-0.3711, -1.9353, -0.4605, -0.2917], ... [ 0.1815, -1.0111, 0.9805, -1.5923], ... [ 0.1062, 1.4581, 0.7759, -1.2344], ... ... Read More
-
PyTorch bmm()
PyTorch - torch.bmm[1] input = torch.randn(10, 3, 4) mat2 = torch.randn(10, 4, 5) res = torch.bmm(input, mat2) res.size() # torch.Size([10, 3, 5]) explain Performs a batch matrix-matrix product of matrices stored in input and mat2. Input과 mat2에 저장된 행렬의 batch matrix-matrix 곱셈을 수행한다. input and mat2 must be 3-D tensors e... Read More
-
Torchvision make_grid()
Pytorch - torchvision.utils.make_grid[1] torchvision.utils.make_grid( tensor: Union[Tensor, List[Tensor]], nrow: int = 8, padding: int = 2, normalize: bool = False, value_range: Optional[Tuple[int, int]] = None, scale_each: bool = False, pad_value: float = 0.0, **kwargs ) -> Tensor tensor (Tensor o... Read More