Created
August 3, 2020 21:19
-
-
Save ruotianluo/54c25460b2ca43a274f50e1a7daa409a to your computer and use it in GitHub Desktop.
pthread
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
import torch.nn as nn | |
class X(nn.Module): | |
def __init__(self): | |
super().__init__() | |
self.a = nn.Linear(3,4) | |
def forward(self, x): | |
x = next(self.parameters()) | |
import torchvision | |
data = torchvision.datasets.CIFAR10(root='./', train=False,download=True) | |
loader = torch.utils.data.DataLoader(data, | |
batch_size=4, | |
shuffle=True, | |
num_workers=4, collate_fn=lambda x: x) | |
x = X() | |
x.cuda() | |
x = nn.DataParallel(x) | |
for tmp in loader: | |
x(tmp) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment