Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

How to run with cpu? Actually CUDA is needed anyway? #16

Closed
zszzlmt opened this issue Sep 27, 2018 · 3 comments
Closed

How to run with cpu? Actually CUDA is needed anyway? #16

zszzlmt opened this issue Sep 27, 2018 · 3 comments

Comments

@zszzlmt
Copy link

zszzlmt commented Sep 27, 2018

Hi,I turn to run the code on Linux. But I don't have a computer with NVDIA device, so I tried to run the code only in cpu, like this command:

./python ~/ganomaly/train.py --dataset cifar10 --niter 100 --anomaly_class cat --gpu_ids -1 --ngpu 0

But it turns out that the code needs CUDA device anyway... Are there any options I missed? Thx~!

The running result:
~/anaconda3/bin$ ./python ~/ganomaly/train.py --dataset cifar10 --niter 100 --anomaly_class cat --gpu_ids -1 --ngpu 0 /home/foo/anaconda3/lib/python3.6/site-packages/torchvision-0.2.1-py3.6.egg/torchvision/transforms/transforms.py:188: UserWarning: The use of the transforms.Scale transform is deprecated, please use transforms.Resize instead. Files already downloaded and verified Files already downloaded and verified THCudaCheck FAIL file=/opt/conda/conda-bld/pytorch_1535491974311/work/aten/src/THC/THCGeneral.cpp line=74 error=35 : CUDA driver version is insufficient for CUDA runtime version Traceback (most recent call last): File "/home/foo/ganomaly/train.py", line 39, in <module> model = Ganomaly(opt, dataloader) File "/home/foo/ganomaly/lib/model.py", line 71, in __init__ self.netg = NetG(self.opt).to(self.device) File "/home/foo/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 379, in to return self._apply(convert) File "/home/foo/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 185, in _apply module._apply(fn) File "/home/foo/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 185, in _apply module._apply(fn) File "/home/foo/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 185, in _apply module._apply(fn) File "/home/foo/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 191, in _apply param.data = fn(param.data) File "/home/foo/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 377, in convert return t.to(device, dtype if t.is_floating_point() else None, non_blocking) RuntimeError: cuda runtime error (35) : CUDA driver version is insufficient for CUDA runtime version at /opt/conda/conda-bld/pytorch_1535491974311/work/aten/src/THC/THCGeneral.cpp:74

@zszzlmt
Copy link
Author

zszzlmt commented Sep 27, 2018

it seems that even though i added the option "--gpu_ids -1", the self.device still have value cuda:0

self.device = torch.device("cuda:0" if self.opt.gpu_ids!=-1 else "cpu")

why
qaq

@zszzlmt
Copy link
Author

zszzlmt commented Sep 27, 2018

And I skipped this line, force self.device to be "cpu", but the problem is still there

THCudaCheck FAIL file=/opt/conda/conda-bld/pytorch_1535491974311/work/aten/src/THC/THCGeneral.cpp line=74 error=35 : CUDA driver version is insufficient for CUDA runtime version
Traceback (most recent call last):
File "/home/foo/ganomaly/train.py", line 43, in
model.train()
File "/home/foo/ganomaly/lib/model.py", line 285, in train
self.train_epoch()
File "/home/foo/ganomaly/lib/model.py", line 255, in train_epoch
self.optimize()
File "/home/foo/ganomaly/lib/model.py", line 187, in optimize
self.update_netd()
File "/home/foo/ganomaly/lib/model.py", line 146, in update_netd
self.fake, self.latent_i, self.latent_o = self.netg(self.input)
File "/home/foo/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/home/foo/ganomaly/lib/networks.py", line 173, in forward
latent_i = self.encoder1(x)
File "/home/foo/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/home/foo/ganomaly/lib/networks.py", line 72, in forward
if isinstance(input.data, torch.cuda.FloatTensor) and self.ngpu > 1:
RuntimeError: cuda runtime error (35) : CUDA driver version is insufficient for CUDA runtime version at /opt/conda/conda-bld/pytorch_1535491974311/work/aten/src/THC/THCGeneral.cpp:74

@samet-akcay
Copy link
Owner

I've updated the repo now. You could run the code on CPU via the following command: python train.py --device cpu. However, this is not recommended since training on CPU takes much more time than training on GPU.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants