Skip to content

Commit f89a371

Browse files
huqinghaosoumith
authored andcommitted
fix a bug in DCGAN (pytorch#121)
Using single GPU in DCGAN caused an error because 'gpu_ids' in forward function will be None .
1 parent 0bdcb42 commit f89a371

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

dcgan/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def __init__(self, ngpu):
129129

130130
def forward(self, input):
131131
gpu_ids = None
132-
if isinstance(input.data, torch.cuda.FloatTensor) and self.ngpu > 1:
132+
if isinstance(input.data, torch.cuda.FloatTensor) and self.ngpu >= 1:
133133
gpu_ids = range(self.ngpu)
134134
return nn.parallel.data_parallel(self.main, input, gpu_ids)
135135

@@ -168,7 +168,7 @@ def __init__(self, ngpu):
168168

169169
def forward(self, input):
170170
gpu_ids = None
171-
if isinstance(input.data, torch.cuda.FloatTensor) and self.ngpu > 1:
171+
if isinstance(input.data, torch.cuda.FloatTensor) and self.ngpu > =1:
172172
gpu_ids = range(self.ngpu)
173173
output = nn.parallel.data_parallel(self.main, input, gpu_ids)
174174
return output.view(-1, 1)

0 commit comments

Comments
 (0)