pytorch parallelize for loop of Cross Validation
I have a cuda9-docker with tensorflow and pytorch installed, I am doing cross validation on an image dataset. Currently I am using a for loop to do the cross validation. Something like

for data_train, data_test in sklearn.kfold(5, all_data):
  train(data_train)
  test(data_test)


But the for loop takes too long, will the following code work to parallelize the for loop? Maybe there is already a solution. But this is not Data Parallelization.

from multiprocessing import Pool

def f(trainset, testset):
    train_result = train(trainset)
    test_result = test(testset)
    save_train_result()
    save_test_result()

if __name__ == '__main__':
    with Pool(5) as p:
        print(p.map(f, sklearn.cvfold(5, all_data)))


I am not sure if the multiprocessing will only paralize the cpu or both cpu and gpu? This might be easiler than doing parallel in side  a model i guess like https://discuss.pytorch.org/t/parallelize-simple-for-loop-for-single-gpu/33701
since in my case, there is no need to communicate across each process?

You use try horovod with PyTorch.
ResNet50 example is here:
https://github.com/horovod/horovod/blob/master/examples/pytorch/pytorch_imagenet_resnet50.py
horovod-related changes should be small and isolated.
