【发布时间】:2020-11-16 09:19:09
【问题描述】:
我一直在谷歌搜索,但似乎无法找到 Pytorch-Lightning 中是否有 multiprocessing 模块,就像 Pytorch 有一个 torch.multiprocessing 模块一样。
有谁知道 Pytorch-Lightning 是否有这个(或 Joblib 类似的)模块?我正在寻找一个 Pytorch-Lightning 模块,它允许我在多个 GPU 上进行并行处理
非常感谢。
编辑:更具体地说,我正在 Pytorch-Lightning 中寻找一个 multiprocessing 模块,它允许我在多个 GPU 上并行处理非神经网络计算,例如:
import numpy as np
import torch
from torch.multiprocessing import Pool
X = np.array([[1, 3, 2, 3], [2, 3, 5, 6], [1, 2, 3, 4]])
X = torch.DoubleTensor(X)
def X_power_func(j):
X_power = X.cuda()**j
return X_power
if __name__ == '__main__':
with Pool(processes = 2) as p: # Parallelizing over 2 GPUs
results = p.map(X_power_func, range(4))
results
【问题讨论】:
-
我也在想同样的事情。基本上我需要运行非训练过程。
标签: python multiprocessing pytorch gpu pytorch-lightning