CCPD icon indicating copy to clipboard operation
CCPD copied to clipboard

error self.backends[name].load() with pyTorch 1.0.0

Open czero69 opened this issue 6 years ago • 10 comments

I got error in roi pooling for return self.backends[name].load(), while trying to run demo.py. my env:

CUDA 10.0 Python 2.7.15 |Anaconda, Inc.

print(torch.version) 1.0.0

replacing self._backend = type2backend[type(input)] with self._backend = type2backend[input.type()] solved the problem

I suspect I have newer pytorch. See also: https://discuss.pytorch.org/t/keyerror-class-torch-tensor/22560

full error code:

True Traceback (most recent call last): File "demo.py", line 273, in fps_pred, y_pred = model_conv(x) File "/home/kamil/miniconda2/lib/python2.7/site-packages/torch/nn/modules/module.py", line 489, in call result = self.forward(*input, **kwargs) File "/home/kamil/miniconda2/lib/python2.7/site-packages/torch/nn/parallel/data_parallel.py", line 141, in forward return self.module(*inputs[0], **kwargs[0]) File "/home/kamil/miniconda2/lib/python2.7/site-packages/torch/nn/modules/module.py", line 489, in call result = self.forward(*input, **kwargs) File "demo.py", line 229, in forward roi1 = roi_pooling_ims(_x1, boxNew.mm(p1), size=(16, 8)) File "/home/kamil/programy/CCPD/rpnet/roi_pooling.py", line 73, in roi_pooling_ims output.append(adaptive_max_pool(im, size)) File "/home/kamil/programy/CCPD/rpnet/roi_pooling.py", line 35, in adaptive_max_pool return AdaptiveMaxPool2d(size[0], size[1])(input) File "/home/kamil/programy/CCPD/rpnet/roi_pooling.py", line 18, in forward self._backend = type2backend[type(input)] File "/home/kamil/miniconda2/lib/python2.7/site-packages/torch/_thnn/init.py", line 15, in getitem return self.backends[name].load() KeyError: <class 'torch.Tensor'>

czero69 avatar Dec 21 '18 19:12 czero69

i have meet the same problem,are you solved it ?

HuangSanLi avatar Jan 02 '19 03:01 HuangSanLi

replacing self._backend = type2backend[type(input)] with self._backend = type2backend[input.type()] solved the problem

czero69 avatar Jan 02 '19 22:01 czero69

thanks so much .

HuangSanLi avatar Jan 03 '19 01:01 HuangSanLi

Ty

gqjia avatar Jan 08 '19 10:01 gqjia

thanks

ww451575464 avatar Mar 14 '19 06:03 ww451575464

thanks

liuqc11 avatar Jun 19 '19 07:06 liuqc11

Did it like you did, but there was a new error.

True Traceback (most recent call last): File "demo.py", line 275, in fps_pred, y_pred = model_conv(x) File "/home/fan/anaconda3/envs/tf/lib/python3.7/site-packages/torch/nn/modules/module.py", line 493, in call result = self.forward(*input, **kwargs) File "/home/fan/anaconda3/envs/tf/lib/python3.7/site-packages/torch/nn/parallel/data_parallel.py", line 150, in forward return self.module(*inputs[0], **kwargs[0]) File "/home/fan/anaconda3/envs/tf/lib/python3.7/site-packages/torch/nn/modules/module.py", line 493, in call result = self.forward(*input, **kwargs) File "demo.py", line 230, in forward roi1 = roi_pooling_ims(_x1, boxNew.mm(p1), size=(16, 8)) File "/home/fan/CCPD-master/rpnet/roi_pooling.py", line 74, in roi_pooling_ims output.append(adaptive_max_pool(im, size)) File "/home/fan/CCPD-master/rpnet/roi_pooling.py", line 36, in adaptive_max_pool return AdaptiveMaxPool2d(size[0], size[1])(input) File "/home/fan/CCPD-master/rpnet/roi_pooling.py", line 20, in forward self._backend.SpatialAdaptiveMaxPooling_updateOutput( File "/home/fan/anaconda3/envs/tf/lib/python3.7/site-packages/torch/_thnn/utils.py", line 27, in getattr raise NotImplementedError NotImplementedError

Is this the need to define the subclass SpatialAdaptiveMaxPooling_updateOutput? Could anybody help me?

Fansgithub2019 avatar Jul 07 '19 06:07 Fansgithub2019

I also have the same problem with Pytorch 1.1 and Windows. Perhaps downgrading to pytorch 0.4 solves the problem.

ggsggs avatar Jul 12 '19 15:07 ggsggs

How to downgrade to pytorch 0.4?Remove Pytorch 1.1 and install pytorch 0.4 ?

Fansgithub2019 avatar Jul 17 '19 07:07 Fansgithub2019

I am not the best person to recommend but: I would create a new virtual environment and install all required packages.

If you are using conda, conda create - n yourenvname python=x.x source activate yourenvname and then install all packages you need with conda install yourpackage1

And then install the pytorch version that are used in this repo.

On Wed, 17 Jul 2019, 08:49 Fansgithub2019, [email protected] wrote:

How to downgrade to pytorch 0.4?Remove Pytorch 1.1 and install pytorch 0.4 ?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/detectRecog/CCPD/issues/17?email_source=notifications&email_token=AKOJJ3DBFXSKOVDTDTIE2PTP73FIRA5CNFSM4GL3T3T2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2DLD3Q#issuecomment-512143854, or mute the thread https://github.com/notifications/unsubscribe-auth/AKOJJ3GKVIRSEISWE4G2ATLP73FIRANCNFSM4GL3T3TQ .

ggsggs avatar Jul 17 '19 08:07 ggsggs