d3s icon indicating copy to clipboard operation
d3s copied to clipboard

TypeError: `__cuda_array_interface__` must be a dict

Open hudfdfdf opened this issue 4 years ago • 6 comments

File "/opt/research2/d3s/pytracking/tracker/segm/segm.py", line 96, in initialize feat_max_stride = max(self.params.features_filter.stride()) File "/opt/research2/d3s/pytracking/features/extractor.py", line 66, in stride return torch.Tensor(TensorList([f.stride() for f in self.features if self._return_feature(f)]).unroll()) TypeError: __cuda_array_interface__ must be a dict

I encountered the above problem while running your code, can you help to solve it?

hudfdfdf avatar Jun 08 '20 07:06 hudfdfdf

I suppose that the problem is in library versions. I have: Python 3.7.4, PyTorch 1.1.0, Cuda 9.0.176, cudnn 7.5.1, torchvision 0.3.0, cudatoolkit 9.0 It seems that a similar issue was discussed here: https://github.com/visionml/pytracking/issues/61

alanlukezic avatar Jun 09 '20 07:06 alanlukezic

I met the same issue. Here is how I solve it and go on. For your reference. In features/extractor.py:65, Comment out original return line, and add lines to put values into python List.

def stride(self): tmp = TensorList([f.stride() for f in self.features if self._return_feature(f)]).unroll() tmpList = [] for i in range(len(tmp)): tmpList.append(tmp[i]) return torch.Tensor(tmpList) #return torch.Tensor(TensorList([f.stride() for f in self.features if self._return_feature(f)]).unroll())

wenching33 avatar Sep 23 '20 02:09 wenching33

This problem is caused by using low version pytracking repo, and you can solve like this: Firstly, add these two lines in class TensorList(list) in pytracking/libs/tensorlist.py:

def list(self):
    return list(self)

And then, modify stride method like this in class MultiResolutionExtractor(ExtractorBase) in pytracking/features/extractor.py

def stride(self):
    return torch.Tensor(TensorList([f.stride() for f in self.features if self._return_feature(f)]).unroll().list())

laisimiao avatar Nov 30 '20 08:11 laisimiao

extractor.py

def stride(self):
    sss=TensorList([f.stride() for f in self.features if self._return_feature(f)]).unroll()
    usus=[]
    for i in range(0,len(sss)):
        usus.append(sss[i])
    return torch.Tensor(usus)

micheal2019 avatar Feb 05 '21 05:02 micheal2019

Delete the 'Torch.tensor' can solve the problem

jiaqinxu avatar Mar 10 '21 07:03 jiaqinxu

This problem is caused by using low version pytracking repo, and you can solve like this: Firstly, add these two lines in class TensorList(list) in pytracking/libs/tensorlist.py:

def list(self):
    return list(self)

And then, modify stride method like this in class MultiResolutionExtractor(ExtractorBase) in pytracking/features/extractor.py

def stride(self):
    return torch.Tensor(TensorList([f.stride() for f in self.features if self._return_feature(f)]).unroll().list())

Thanks, it works.

bamboopu avatar Apr 08 '22 06:04 bamboopu