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

When I train with CPU, the error message shows that the parameter types are inconsistent #27

Open
linzhang92 opened this issue Feb 1, 2021 · 1 comment

Comments

@linzhang92
Copy link

I'm trying to train my network with CPU,and the command is"python train.py --img 640 --batch 2 --epochs 2 --data coco.yaml --weights yolov5s.pt --device cpu".

But I received an error:

Traceback (most recent call last):
File "train.py", line 518, in
train(hyp, opt, device, tb_writer, wandb)
File "train.py", line 412, in train
results, _, _ = test.test(opt.data,
File "D:\Algorithm\algorithm_lin\PANDA-project-tianchi-zl\yolov5-master\test.py", line 118, in test
inf_out, train_out = model(img, augment=augment) # inference and training outputs
File "D:\SoftwareInstallation\Anaconda\envs\yolov5_env\lib\site-packages\torch\nn\modules\module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "D:\Algorithm\algorithm_lin\PANDA-project-tianchi-zl\yolov5-master\models\yolo.py", line 119, in forward
return self.forward_once(x, profile) # single-scale inference, train
File "D:\Algorithm\algorithm_lin\PANDA-project-tianchi-zl\yolov5-master\models\yolo.py", line 135, in forward_once
x = m(x) # run
File "D:\SoftwareInstallation\Anaconda\envs\yolov5_env\lib\site-packages\torch\nn\modules\module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "D:\Algorithm\algorithm_lin\PANDA-project-tianchi-zl\yolov5-master\models\common.py", line 112, in forward
return self.conv(torch.cat([x[..., ::2, ::2], x[..., 1::2, ::2], x[..., ::2, 1::2], x[..., 1::2, 1::2]], 1))
File "D:\SoftwareInstallation\Anaconda\envs\yolov5_env\lib\site-packages\torch\nn\modules\module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "D:\Algorithm\algorithm_lin\PANDA-project-tianchi-zl\yolov5-master\models\common.py", line 40, in fuseforward
return self.act(self.conv(x))
File "D:\SoftwareInstallation\Anaconda\envs\yolov5_env\lib\site-packages\torch\nn\modules\module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "D:\SoftwareInstallation\Anaconda\envs\yolov5_env\lib\site-packages\torch\nn\modules\conv.py", line 431, in forward
return self._conv_forward(input, self.weight)
File "D:\SoftwareInstallation\Anaconda\envs\yolov5_env\lib\site-packages\torch\nn\modules\conv.py", line 427, in _conv_forward
return F.conv2d(input, weight, self.bias, self.stride,
RuntimeError: Input type (torch.FloatTensor) and weight type (torch.HalfTensor) should be the same

How should I solve this problem?Thanks!

@DataXujing
Copy link
Owner

There are differences between CPU and GPU versions of pytorch, and we do not recommend that you use CPU to train yolov5。

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