-
[yongggg's] Big-size image dataset load TipGPUTraining & View 2023. 2. 1. 14:44
폴더 안에 이미지가 있을 때, 모든 이미지를 로드하면 gpu 및 ram이 터진다.
아래와 같이 dataset을 구성하면 좋다.
class MyDataset(torch.utils.data.Dataset): def __init__(self, file_x,: str file_y: str) -> None: super().__init__() # file won't be loaded with mmap_mode != None self.file_x = np.load(file_x, mmap_mode='r') self.file_y = np.load(file_y, mmap_mode='r') def __getitem__(self, idx: int) -> Tuple[torch.Tensor, torch.Tensor]: return (torch.from_numpy(self.file_x[idx]), torch.from_numpy(self.file_y[idx])) def __len__(self) -> int: return len(self.file_x)
'GPUTraining & View' 카테고리의 다른 글
[yongggg's] FSDP: Fully Sharded Data Parallel (1) 2024.02.06 [yongggg's] DDP (2) 2023.12.14 [yongggg's] 서버에 딥러닝 환경 설치하기 (Ubuntu 20.04) (0) 2022.11.24 [yongggg's] Nvidia-smi(Failed to initialize NVML: Driver/library version mismatch) (1) 2022.08.16 [yongggg's] pytorch 딥러닝 GPU 메모리 관리 (IterableDataset) (1) 2022.05.03