반응형

Python 266

[Pytorch Ligtning] RuntimeError: t == DeviceType::CUDAINTERNAL ASSERT FAILED at "/opt/conda/conda-bld/pytorch_1634272068694/work/c10/cuda/impl/CUDAGuardImpl.h":24, please report a bug to PyTorch.

RuntimeError: t == DeviceType::CUDAINTERNAL ASSERT FAILED at "/opt/conda/conda-bld/pytorch_1634272068694/work/c10/cuda/impl/CUDAGuardImpl.h":24, please report a bug to PyTorch. 에러가 발생했다. Pytorch Lightning을 사용하다 발생한 에러인데, torchmetric에서 불러온 PSNR 함수를 .cuda()로 보내지 않아 발생한 오류였다. Pytorch Lightning이 torchmetric에서 불러온 PSNR 함수를 자동으로 cuda로 전달하지 않나보다. psnr = PSNR().cuda()

[Error] h5py.FIle()에서 경고 메세지 H5pyDeprecationWarning: The default file mode will change to 'r'

h5py file을 불러오는 코드를 다음과 같이 작성했다. file = h5py.File(path2h5) train_data = file['data'][:].astype('float32') train_label = file['label'][:].astype('float32') file.close() 다음과 같은 경고 메세지가 발생 dataset.py:10: H5pyDeprecationWarning: The default file mode will change to 'r' (read-only) in h5py 3.0. To suppress this warning, pass the mode you need to h5py.File(), or set the global default h5.get_config()...

[Pytorch] Load state_dict로 인한 out of memory

back = Back().cuda() state_dict = torch.load(config['back_init_model']) back.load_state_dict(state_dict['state_dict']) 모델을 GPU에 올린뒤에 load 명령어로 state_dict 파일을 불러오고 모델.load_state_dict로 불러온 state_dict을 적용하면 GPU 메모리가 낭비된다. 즉 CUDA out of memory가 발생할 수 있다는 것. load_state_dict이 적용된 모델과 처음에 정의한 모델이 함께 GPU에 올라가서 발생한 문제인 것 같다. 먼저 CPU 에 모델을 올리고 나서 load_state_dict으로 state_dict을 적용한 후에 GPU에 올리면 된다. back = Bac..

[PyTorch] RuntimeError("grad can be implicitly created only for scalar outputs")

UserWarning: Was asked to gather along dimension 0, but all input tensors were scalars; will instead unsqueeze and return a vector RuntimeError("grad can be implicitly created only for scalar outputs") 위와 같은 에러가 발생했다. loss.backward() 에서 발생했는데.. loss.shape = ([2]) 로 되어 있기 때문이다. 파이토치 DP를 쓰면서 loss가 gpu 수 만큼 반환하게 되어, vector를 출력하게 된 것이다. loss.backward()를 위해서는 loss가 scalar이어야 하낟. 따라서 loss.mean().backw..

[PyTorch] Error: one of the variables needed for gradient computation has been modified by an inplace operation

파이토치 오류 https://discuss.pytorch.org/t/one-of-the-variables-needed-for-gradient-computation-has-been-modified-by-an-inplace-operation-torch-cuda-floattensor-3-48-3-3-is-at-version-2-expected-version-1-instead/83241 One of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [3, 48, When I was training the GAN, the first iteration worked ..

반응형