Skip to content

请问爆显存了该怎么解决 #2

Description

@Allogeness

在开始训练模型时会显示如下错误:
OutOfMemoryError Traceback (most recent call last)
in <cell line: 2>()
1 # 正式开启训练
----> 2 train_loss_hist, train_acc_hist, test_loss_hist, test_acc_hist, best_model = train(model,
3 criterion,optimizer, train_dataloader, val_dataloader, epochs = 1, device = device)

12 frames
in forward(self, E)
24 fft_c = torch.fft.fft2(E) # 对电场E进行二维傅里叶变换
25 c = torch.fft.fftshift(fft_c) # 将零频移至张量中心
---> 26 angular_spectrum = torch.fft.ifft2(torch.fft.ifftshift(c * self.phase)) # 卷积后逆变换得到响应的角谱
27 return angular_spectrum

OutOfMemoryError: CUDA out of memory. Tried to allocate 1.56 GiB. GPU 0 has a total capacty of 14.75 GiB of which 487.06 MiB is free. Process 1964 has 14.27 GiB memory in use. Of the allocated memory 14.14 GiB is allocated by PyTorch, and 14.04 MiB is reserved by PyTorch but unallocated. If reserved but unallocated memory is large try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF

我尝试把BATCH_SIZE改小也没有解决问题。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions