alanlukezic / d3s

D3S - Discriminative Single Shot Segmentation Tracker (CVPR 2020)
265 stars 56 forks source link

TypeError: `__cuda_array_interface__` must be a dict #7

Open hudfdfdf opened 4 years ago

hudfdfdf commented 4 years ago

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?

alanlukezic commented 4 years ago

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

wenching33 commented 4 years ago

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())

laisimiao commented 3 years ago

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())
micheal2019 commented 3 years ago

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)
jiaqinxu commented 3 years ago

Delete the 'Torch.tensor' can solve the problem

bamboopu commented 2 years ago

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.