@smu226 To answer your question on training large datasets like Imagenet, such large datasets are usually loaded in batches(using torch.utils.data.Dataset in Pytorch). Images are usually saved in disks and loaded during training one by one instead of loading one huge numpy/hdf5 file. If you have the luxury of affording more RAM, then loading all at once into memory and using them during training is always good since it much faster(avoids disk read latency) compared to loading on the fly for every batch.
Since you say that RAM being the issue here, you can try using low precision datatype such as float16 which can save you some memory during tensor conversion.