progressive-growing-of-gans.pytorch icon indicating copy to clipboard operation
progressive-growing-of-gans.pytorch copied to clipboard

RuntimeError: randperm is only implemented for CPU

Open Arsey opened this issue 7 years ago • 1 comments

The code doesn't work in Pytorch v0.4.0 (latest stable release):

Exception KeyError: KeyError(<weakref at 0x7f1fd0a76aa0; to 'tqdm' at 0x7f1fd0aad6d0>,) in <bound method tqdm.__del__ of   0%|                                                                                                                                                                                                                                                 | 0/18750 [00:00<?, ?it/s]> ignored
Traceback (most recent call last):
  File "pggan.py", line 365, in <module>
    pggan.train()
  File "pggan.py", line 269, in train
    self.x.data = self.feed_interpolated_input(self.loader.get_batch())
  File "Progressive-Growing-of-GANs/dataloader.py", line 57, in get_batch
    dataIter = iter(self.dataloader)
  File "Progressive-Growing-of-GANs-py2/lib/python2.7/site-packages/torch/utils/data/dataloader.py", line 451, in __iter__
    return _DataLoaderIter(self)
  File "Progressive-Growing-of-GANs-py2/lib/python2.7/site-packages/torch/utils/data/dataloader.py", line 247, in __init__
    self._put_indices()
  File "Progressive-Growing-of-GANs-py2/lib/python2.7/site-packages/torch/utils/data/dataloader.py", line 295, in _put_indices
    indices = next(self.sample_iter, None)
  File "Progressive-Growing-of-GANs-py2/lib/python2.7/site-packages/torch/utils/data/sampler.py", line 138, in __iter__
    for idx in self.sampler:
  File "Progressive-Growing-of-GANs-py2/lib/python2.7/site-packages/torch/utils/data/sampler.py", line 51, in __iter__
    return iter(torch.randperm(len(self.data_source)).tolist())
RuntimeError: randperm is only implemented for CPU

Here people recommend writing device-agnostic code to avoid such problems. What would you suggest as a quick fix?

Arsey avatar May 29 '18 13:05 Arsey

I am working on updating the code to version 0.4.1 along with results in somedays. That'll remove this problem. ✌️

RahulBhalley avatar Oct 04 '18 15:10 RahulBhalley