Skip to content

Commit

Permalink
fix a bug in DCGAN (pytorch#121)
Browse files Browse the repository at this point in the history
Using single GPU in DCGAN caused an error because  'gpu_ids'  in forward function will be None .
  • Loading branch information
huqinghao authored and soumith committed Apr 5, 2017
1 parent 0bdcb42 commit f89a371
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions dcgan/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def __init__(self, ngpu):

def forward(self, input):
gpu_ids = None
if isinstance(input.data, torch.cuda.FloatTensor) and self.ngpu > 1:
if isinstance(input.data, torch.cuda.FloatTensor) and self.ngpu >= 1:
gpu_ids = range(self.ngpu)
return nn.parallel.data_parallel(self.main, input, gpu_ids)

Expand Down Expand Up @@ -168,7 +168,7 @@ def __init__(self, ngpu):

def forward(self, input):
gpu_ids = None
if isinstance(input.data, torch.cuda.FloatTensor) and self.ngpu > 1:
if isinstance(input.data, torch.cuda.FloatTensor) and self.ngpu > =1:
gpu_ids = range(self.ngpu)
output = nn.parallel.data_parallel(self.main, input, gpu_ids)
return output.view(-1, 1)
Expand Down

0 comments on commit f89a371

Please sign in to comment.