Что лучше хранить: тензоры CUDA или ЦП, загружаемые факелом DataLoader?Python

Программы на Python
Гость
Что лучше хранить: тензоры CUDA или ЦП, загружаемые факелом DataLoader?

Сообщение Гость »


I am working on a project where I aim to train a PyTorch model on multiple GPUs. My input data is stored in separate files for each training example, and during preprocessing, I save them using the

Код: Выделить всё

torch.save
method to .pt files. Later, I load these files using DataLoader, where I want to set num_workers > 0 to speed up the process. However, it seems that num_workers can only be set to >0 when the input data is on CPU.

My question is: Should I save CUDA tensors already and just use num_workers=0, or should I store CPU tensors, set num_workers > 0, and then move the batch as a whole to GPU?

I'm uncertain which approach would be more efficient for training on multiple GPUs. Any insights or best practices on this matter would be greatly appreciated.


Источник: https://stackoverflow.com/questions/781 ... dataloader

Вернуться в «Python»