sagiebenaim / DistanceGAN

Pytorch implementation of "One-Sided Unsupervised Domain Mapping" NIPS 2017

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

can it works on cpu..

diliphadoop742 opened this issue · comments

(/home/hadoop/anaconda2) hadoop@hadoop:~/GAN/DistanceGAN-master$ python ./discogan_arch/distance_gan_model.py --task_name='celebA' --style_A='Eyeglasses' --constraint='Male' --constraint_type=1
Traceback (most recent call last):
File "./discogan_arch/distance_gan_model.py", line 332, in
model.run()
File "./discogan_arch/distance_gan_model.py", line 173, in run
self.initialize()
File "/home/hadoop/GAN/DistanceGAN-master/discogan_arch/disco_gan_model.py", line 142, in initialize
self.test_A = self.test_A.cuda()
File "/home/hadoop/anaconda2/lib/python2.7/site-packages/torch/autograd/variable.py", line 243, in cuda
return CudaTransfer(device_id, async)(self)
File "/home/hadoop/anaconda2/lib/python2.7/site-packages/torch/autograd/_functions/tensor.py", line 160, in forward
return i.cuda(async=self.async)
File "/home/hadoop/anaconda2/lib/python2.7/site-packages/torch/_utils.py", line 65, in cuda
return new_type(self.size()).copy
(self, async)
File "/home/hadoop/anaconda2/lib/python2.7/site-packages/torch/cuda/init.py", line 272, in new
_lazy_init()
File "/home/hadoop/anaconda2/lib/python2.7/site-packages/torch/cuda/init.py", line 84, in _lazy_init
_check_driver()
File "/home/hadoop/anaconda2/lib/python2.7/site-packages/torch/cuda/init.py", line 58, in _check_driver
http://www.nvidia.com/Download/index.aspx""")
AssertionError:
Found no NVIDIA driver on your system. Please check that you
have an NVIDIA GPU and installed a driver from
http://www.nvidia.com/Download/index.aspx



i was tried this code on cpu and got the above issue.. Is it possible to run on cpu??
can you suggest me requirement of hardware components and changes required for code from gpu to cpu......

Simply specify as an argument --cuda='false'. This will run it on CPU.
Running on CPU can be time consuming so you can either use self distance (--use_self_distance) or reduce batch size using --batch_size, to, say 2. Also you can reduce preprocessing time by setting --max_items to, say, 400.

(/home/chary/work/anaconda2) chary@chary:~/Downloads/DistanceGAN-master$ python ./discogan_arch/distance_gan_model.py --task_name='celebA' --style_A='Eyeglasses' --constraint='Male' --constraint_type=1 --cuda='false' --use_self_distance --max_items=400 --batch_size=2
Expectation for dataset A: 0.284713
Expectation for dataset B: 0.281350
Std for dataset A: 0.071673
Std for dataset B: 0.064328
epoch #0| 0%| |ETA: --:--:--Traceback (most recent call last):
File "./discogan_arch/distance_gan_model.py", line 332, in
model.run()
File "./discogan_arch/distance_gan_model.py", line 229, in run
self.fm_loss_A = self.get_fm_loss(A_feats_real, A_feats_fake)
File "/home/chary/Downloads/DistanceGAN-master/discogan_arch/disco_gan_model.py", line 56, in get_fm_loss
loss = self.feat_criterion(l2, Variable(torch.ones(l2.size())).cuda())
File "/home/chary/work/anaconda2/lib/python2.7/site-packages/torch/autograd/variable.py", line 243, in cuda
return CudaTransfer(device_id, async)(self)
File "/home/chary/work/anaconda2/lib/python2.7/site-packages/torch/autograd/_functions/tensor.py", line 160, in forward
return i.cuda(async=self.async)
File "/home/chary/work/anaconda2/lib/python2.7/site-packages/torch/_utils.py", line 65, in cuda
return new_type(self.size()).copy
(self, async)
File "/home/chary/work/anaconda2/lib/python2.7/site-packages/torch/cuda/init.py", line 272, in new
_lazy_init()
File "/home/chary/work/anaconda2/lib/python2.7/site-packages/torch/cuda/init.py", line 84, in _lazy_init
_check_driver()
File "/home/chary/work/anaconda2/lib/python2.7/site-packages/torch/cuda/init.py", line 58, in _check_driver
http://www.nvidia.com/Download/index.aspx""")
AssertionError:
Found no NVIDIA driver on your system. Please check that you
have an NVIDIA GPU and installed a driver from
http://www.nvidia.com/Download/index.aspx



hello sagiebenaim,

After passing all the arguments whatever you mentioned got the same issue (above). Is "NVIDIA Driver" compulsory to run this code..?

Is this the only thing that we have to change from GPU to CPU is " --cuda='false' " , are there any changes required in code to run on cpu..?

I made a change in discogan_arch/disco_gan_model.py. Please update your repository. This should work now.

For each epoch, test images are saved inside "results" folder with the epoch number, according to the experiment you run. Usually, around 50 epochs are sufficient for "Eyeglasses" experiment, but for a batch size of 2, you may need more. You can specify how many epochs using using --epoch_size (you can see all options in ./discogan_arch/discogan_arch_options/options.py).

For testing, if you require test images, that this is shown in "results" folder as I mentioned. If you require numerical tests, than you'll have to take VGG representation of source and target images, as described in the article (public VGG code can be used for this). Hope this helps.