Parallel processing 如何在GPU中并行训练参数不同的相同torch.nn.模块
我有两个像这样的pytorch nn.模块的实例Parallel processing 如何在GPU中并行训练参数不同的相同torch.nn.模块,parallel-processing,pytorch,Parallel Processing,Pytorch,我有两个像这样的pytorch nn.模块的实例obj1和obj2 class Embedding(nn.Module): def __init__(self, dropout=0, emb_dim): self.lin = nn.Linear(1, emb_dim) init.xavier_uniform(self.lin1.weight, gain=np.sqrt(2.0)) def forward(self, values)
obj1
和obj2
class Embedding(nn.Module):
def __init__(self, dropout=0, emb_dim):
self.lin = nn.Linear(1, emb_dim)
init.xavier_uniform(self.lin1.weight, gain=np.sqrt(2.0))
def forward(self, values)
return F.relu(self.lin1(values))
我有两个数据张量t1
,t2
我想做什么
obj1.forward(t1)
obj2.forward(t2)
在GPU中并行,直观地说,这是可能的,因为我执行相同的操作,但使用不同的数据。
有什么方法可以使用pytorch来做到这一点吗?我认为这可以通过创建两个不同的优化器
opt1
和opt2
,使用不同的参数,并使用它们独立地更新每个nn.Module
模块来实现。您想在不同的GPU上具体运行这两个层,还是想并行化您的应用程序在多个gpu上运行整个模型?Wasi Ahmad我希望能够在一个gpu上同时运行这两个gpu。