Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only CPU machine implementation #6

Closed
Priyankamun opened this issue Feb 27, 2020 · 3 comments
Closed

Only CPU machine implementation #6

Priyankamun opened this issue Feb 27, 2020 · 3 comments

Comments

@Priyankamun
Copy link

I am trying to run the code on a cpu only machine. Please can anyone tell me the changes i need to make in all the codes. Are there any ways to execute on a NO GPU machine?

I have explored a few options but stuck right now at
runfile('C:/Users/Admin/.spyder-py3/Capsule-Forensics-v2-master/train_binary_ffpp.py', wdir='C:/Users/Admin/.spyder-py3/Capsule-Forensics-v2-master')
Namespace(batchSize=32, beta1=0.9, cpu_id=0, dataset='databases/faceforensicspp', disable_random=False, dropout=0.05, imageSize=300, lr=0.0005, manualSeed=None, niter=25, outf='checkpoints/binary_faceforensicspp', resume=0, train_set='train', val_set='validation', workers=0)
Random Seed: 3435
Traceback (most recent call last):

File "C:\Users\Admin.spyder-py3\Capsule-Forensics-v2-master\train_binary_ffpp.py", line 76, in
capsule_loss = model_big.CapsuleLoss(opt.cpu_id)

File "C:\Users\Admin.spyder-py3\Capsule-Forensics-v2-master\model_big.py", line 200, in init
self.cross_entropy_loss.to('cpu')(cpu_id)

File "C:\Users\Admin\Miniconda3\lib\site-packages\torch\nn\modules\module.py", line 493, in call
result = self.forward(*input, **kwargs)

TypeError: forward() missing 1 required positional argument: 'target'

@honghuy127
Copy link
Member

honghuy127 commented Mar 1, 2020

Yes, just simply delete .cuda(...) in the scripts.

To load saved GPU models to CPU-only machine, just modify the load part as follow:
torch.load('my_file.pt', map_location=lambda storage, loc: storage)

@Priyankamun
Copy link
Author

Thank you, I made the changes you mentioned. That got me here:

def forward(self, input, output_size=None):
# type: (Tensor, Optional[List[int]]) -> Tensor
if self.padding_mode != 'zeros':
raise ValueError('Only zeros padding mode is supported for ConvTranspose1d')

    output_padding = self._output_padding(input, output_size, self.stride, self.padding, self.kernel_size)
    return F.conv_transpose1d(
        input, self.weight, self.bias, self.stride, self.padding,
        output_padding, self.groups, self.dilation)

ERROR MESSAGE:
runfile('C:/Users/Priyanka/.spyder-py3/Capsule-Forensics-v2-master/test_binary_ffpp.py', wdir='C:/Users/Priyanka/.spyder-py3/Capsule-Forensics-v2-master')
Reloaded modules: model_big
Namespace(batchSize=32, dataset='databases/faceforensicspp', gpu_id=0, id=21, imageSize=300, outf='checkpoints/binary_faceforensicspp', random=False, test_set='test', workers=0)
Traceback (most recent call last):

File "C:\Users\Admin.spyder-py3\Capsule-Forensics-v2-master\test_binary_ffpp.py", line 63, in
vgg_ext(opt.gpu_id)

File "C:\Users\Admin\Miniconda3\lib\site-packages\torch\nn\modules\module.py", line 493, in call
result = self.forward(*input, **kwargs)

File "C:\Users\Admin.spyder-py3\Capsule-Forensics-v2-master\model_big.py", line 53, in forward
return self.vgg_1(input)

File "C:\Users\Admin\Miniconda3\lib\site-packages\torch\nn\modules\module.py", line 493, in call
result = self.forward(*input, **kwargs)

File "C:\Users\Admin\Miniconda3\lib\site-packages\torch\nn\modules\container.py", line 92, in forward
input = module(input)

File "C:\Users\Admin\Miniconda3\lib\site-packages\torch\nn\modules\module.py", line 493, in call
result = self.forward(*input, **kwargs)

File "C:\Users\Admin\Miniconda3\lib\site-packages\torch\nn\modules\conv.py", line 338, in forward
self.padding, self.dilation, self.groups)

TypeError: conv2d(): argument 'input' (position 1) must be Tensor, not int

Can you please help?

@honghuy127
Copy link
Member

I think this is a bug of PyTorch. Could you check the following link?
'ConvTranspose1d' object has no attribute 'padding_mode'

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

No branches or pull requests

2 participants