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, tbwriter, 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
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, tbwriter, 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!