semantic-segmentation-pytorch icon indicating copy to clipboard operation
semantic-segmentation-pytorch copied to clipboard

Unable to train

Open solodova opened this issue 5 years ago • 3 comments

solodova avatar Oct 26 '19 23:10 solodova

Did you find a solution to this? I am having the same issue! Thanks.

EricaMoreira avatar Dec 05 '19 20:12 EricaMoreira

I've been facing exactly the same errors too. The last one seems related to the fact that model and input don't run on the same device (one on GPU and one on CPU) as suggested here and here. Moreover, the traceback suggests that we need to locate the input into the GPU, because the model is already there.

Here is the modification I applied just before the computation done for the batch forward, it works for me.

# from models/models.py ln. 30
def forward(self, feed_dict, *, segSize=None):
	# if the dataset is loaded as a list, this will
	# raise a TypeError while trying to access it as a dictionary.
	if type(feed_dict) is list:
		feed_dict = feed_dict[0]
		# also, convert to torch.cuda.FloatTensor
		if torch.cuda.is_available():
			feed_dict['img_data'] = feed_dict['img_data'].cuda()
			feed_dict['seg_label'] = feed_dict['seg_label'].cuda()
		else:
			raise RunTimeError('Cannot convert torch.Floattensor into torch.cuda.FloatTensor')

Hope it helps!

Fiordarancio avatar Dec 06 '19 10:12 Fiordarancio

@Fiordarancio it's RuntimeError not RunTimeError

siyangxie avatar Oct 27 '20 09:10 siyangxie