MedicalNet icon indicating copy to clipboard operation
MedicalNet copied to clipboard

你好,我在测试的时候出现了一个问题,请问您知道这是为什么吗

Open nuist-xinyu opened this issue 5 years ago • 2 comments

(MedicalNet) xinyu@xinyu-MS-7B89:~/MedicalNet-master$ python test.py --gpu_id 0 --resume_path trails/models/resnet_50_epoch_199_batch_0.pth.tar --img_list data/val.txt /home/xinyu/MedicalNet-master/models/resnet.py:173: UserWarning: nn.init.kaiming_normal is now deprecated in favor of nn.init.kaiming_normal_. m.weight = nn.init.kaiming_normal(m.weight, mode='fan_out') Processing 1 datas /home/xinyu/MedicalNet-master/data/MRBrainS18/images/imaging4.nii.gz THCudaCheck FAIL file=/pytorch/aten/src/THC/THCGeneral.cpp line=383 error=11 : invalid argument Traceback (most recent call last): File "test.py", line 92, in masks = test(data_loader, net, img_names, sets) File "test.py", line 67, in test mask = ndimage.interpolation.zoom(mask, scale, order=1) File "/home/xinyu/anaconda3/lib/python3.6/site-packages/scipy/ndimage/interpolation.py", line 591, in zoom input = numpy.asarray(input) File "/home/xinyu/anaconda3/lib/python3.6/site-packages/numpy/core/_asarray.py", line 85, in asarray return array(a, dtype, copy=False, order=order) File "/home/xinyu/anaconda3/lib/python3.6/site-packages/torch/tensor.py", line 458, in array return self.numpy() TypeError: can't convert CUDA tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.

nuist-xinyu avatar Nov 21 '19 02:11 nuist-xinyu

File "test.py", line 67, in test mask = ndimage.interpolation.zoom(mask, scale, order=1)

Shold be replaced by mask = ndimage.interpolation.zoom(mask.cpu(), scale, order=1) cause the mask is in GPU by default.

littlelk avatar Mar 07 '20 01:03 littlelk

I met the same problem. Use mask = mask.cpu() will solve it.

DKJoey avatar Nov 26 '20 16:11 DKJoey