sacmehta / ESPNet

ESPNet: Efficient Spatial Pyramid of Dilated Convolutions for Semantic Segmentation
https://sacmehta.github.io/ESPNet/
MIT License
541 stars 112 forks source link

RuntimeError: Expected object of type torch.FloatTensor but found type torch.cuda.FloatTensor for argument #2 'weight' #46

Closed berylyellow closed 5 years ago

berylyellow commented 5 years ago

I run by this:python3 main.py --scaleIn 8 --p 2 --q 8 --onGPU True then get: Total network parameters: 344841 /home/hh/.local/lib/python3.5/site-packages/torch/nn/modules/loss.py:206: UserWarning: NLLLoss2d has been deprecated. Please use NLLLoss instead as a drop-in replacement and see http://pytorch.org/docs/master/nn.html#torch.nn.NLLLoss for more details. warnings.warn("NLLLoss2d has been deprecated. " Data statistics [103.45756 101.83934 101.728714] [69.51785 67.936035 64.71613 ] [4.2652993 1.5139731] Learning rate: 0.0005 Traceback (most recent call last): File "main.py", line 408, in trainValidateSegmentation(parser.parse_args()) File "main.py", line 334, in trainValidateSegmentation train(args, trainLoader_scale1, model, criteria, optimizer, epoch) File "main.py", line 97, in train output = model(input_var) File "/home/hh/.local/lib/python3.5/site-packages/torch/nn/modules/module.py", line 477, in call result = self.forward(*input, kwargs) File "/home/hh/programs/ESPNet_hh/train/Model.py", line 286, in forward output0 = self.level1(input) File "/home/hh/.local/lib/python3.5/site-packages/torch/nn/modules/module.py", line 477, in call result = self.forward(*input, *kwargs) File "/home/hh/programs/ESPNet_hh/train/Model.py", line 33, in forward output = self.conv(input) File "/home/hh/.local/lib/python3.5/site-packages/torch/nn/modules/module.py", line 477, in call result = self.forward(input, kwargs) File "/home/hh/.local/lib/python3.5/site-packages/torch/nn/modules/conv.py", line 301, in forward self.padding, self.dilation, self.groups) RuntimeError: Expected object of type torch.FloatTensor but found type torch.cuda.FloatTensor for argument #2 'weight' I followed by your code,and there is only one class for my dataset to segment. What happened to this porblem?How to change?

sacmehta commented 5 years ago

Seems like you don’t have cuda enabled device

berylyellow commented 5 years ago

I have cuda V9.0.176,pytorch 0.4.1

sacmehta commented 5 years ago

Could you check the value of args.gpu in main.py file?

sacmehta commented 5 years ago

Also, this codebase doesn’t support PyTorch 0.4. Check software requirements

berylyellow commented 5 years ago

Thanks for your help, it works for PyTorch 0.4 anyway. But another thing occurs when I finished training EspNet-C,I want to train ESPNet, but it says: python3 main.py --scaleIn 1 --p 2 --q 8 --decoder True --pretrained ../pretrained/encoder/espnet_p_2_q_8.pth Encoder loaded! Total network parameters: 365109 /home/hh/.local/lib/python3.5/site-packages/torch/nn/modules/loss.py:206: UserWarning: NLLLoss2d has been deprecated. Please use NLLLoss instead as a drop-in replacement and see http://pytorch.org/docs/master/nn.html#torch.nn.NLLLoss for more details. warnings.warn("NLLLoss2d has been deprecated. " Data statistics [103.45756 101.83934 101.728714] [69.51785 67.936035 64.71613 ] [ 4.2652993 10.492059 10.492059 10.492059 10.492059 10.492059 10.492059 10.492059 10.492059 10.492059 10.492059 10.492059 10.492059 10.492059 10.492059 10.492059 10.492059 10.492059 10.492059 1.5139731] Learning rate: 0.0005 Traceback (most recent call last): File "main.py", line 415, in trainValidateSegmentation(parser.parse_args()) File "main.py", line 338, in trainValidateSegmentation train(args, trainLoader_scale1, model, criteria, optimizer, epoch) File "main.py", line 98, in train output = model(input_var) File "/home/hh/.local/lib/python3.5/site-packages/torch/nn/modules/module.py", line 477, in call result = self.forward(*input, kwargs) File "/home/hh/programs/ESPNet_hh/train/Model.py", line 387, in forward comb_l2_l3 = self.up_l2(self.combine_l2_l3(torch.cat([output1_C, output2_c], 1))) #RUM File "/home/hh/.local/lib/python3.5/site-packages/torch/nn/modules/module.py", line 477, in call result = self.forward(*input, *kwargs) File "/home/hh/.local/lib/python3.5/site-packages/torch/nn/modules/container.py", line 91, in forward input = module(input) File "/home/hh/.local/lib/python3.5/site-packages/torch/nn/modules/module.py", line 477, in call result = self.forward(input, kwargs) File "/home/hh/.local/lib/python3.5/site-packages/torch/nn/modules/conv.py", line 691, in forward output_padding, self.groups, self.dilation) RuntimeError: CUDA error: out of memory What does it mean? My device is free now.

sacmehta commented 5 years ago

What is the batch size? I used 6 for ESPNet

berylyellow commented 5 years ago

Thanks for your help, it works.