ValueError: some of the strides of a given numpy array are negative. This is currently not supported, but will be added in future releases.
zhixuanli opened this issue · 4 comments
I'm appreciated for your impressive work!
After configuring everything as your instructions, I get the following error:
[01/10 16:58:55 d2.engine.train_loop]: Starting training from iteration 0
[01/10 16:58:56 d2.engine.hooks]: Total training time: 0:00:00 (0:00:00 on hooks)
Traceback (most recent call last):
File "tools/train_net.py", line 173, in <module>
args=(args,),
File "/home/lzx/Amodal-Segmentation-Based-on-Visible-Region-Segmentation-and-Shape-Prior-main/detectron2/engine/launch.py", line 51, in launch
main_func(*args)
File "tools/train_net.py", line 161, in main
return trainer.train()
File "/home/lzx/Amodal-Segmentation-Based-on-Visible-Region-Segmentation-and-Shape-Prior-main/detectron2/engine/defaults.py", line 416, in train
super().train(self.start_iter, self.max_iter)
File "/home/lzx/Amodal-Segmentation-Based-on-Visible-Region-Segmentation-and-Shape-Prior-main/detectron2/engine/train_loop.py", line 132, in train
self.run_step()
File "/home/lzx/Amodal-Segmentation-Based-on-Visible-Region-Segmentation-and-Shape-Prior-main/detectron2/engine/train_loop.py", line 211, in run_step
data = next(self._data_loader_iter)
File "/home/lzx/anaconda3/envs/aaai21amodal/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 345, in __next__
data = self._next_data()
File "/home/lzx/anaconda3/envs/aaai21amodal/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 838, in _next_data
return self._process_data(data)
File "/home/lzx/anaconda3/envs/aaai21amodal/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 881, in _process_data
data.reraise()
File "/home/lzx/anaconda3/envs/aaai21amodal/lib/python3.6/site-packages/torch/_utils.py", line 394, in reraise
raise self.exc_type(msg)
ValueError: Caught ValueError in DataLoader worker process 1.
Original Traceback (most recent call last):
File "/home/lzx/anaconda3/envs/aaai21amodal/lib/python3.6/site-packages/torch/utils/data/_utils/worker.py", line 178, in _worker_loop
data = fetcher.fetch(index)
File "/home/lzx/anaconda3/envs/aaai21amodal/lib/python3.6/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/home/lzx/anaconda3/envs/aaai21amodal/lib/python3.6/site-packages/torch/utils/data/_utils/fetch.py", line 44, in <listcomp>
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/home/lzx/Amodal-Segmentation-Based-on-Visible-Region-Segmentation-and-Shape-Prior-main/detectron2/data/common.py", line 39, in __getitem__
data = self._map_func(self._dataset[cur_idx])
File "/home/lzx/Amodal-Segmentation-Based-on-Visible-Region-Segmentation-and-Shape-Prior-main/detectron2/utils/serialize.py", line 23, in __call__
return self._obj(*args, **kwargs)
File "/home/lzx/Amodal-Segmentation-Based-on-Visible-Region-Segmentation-and-Shape-Prior-main/detectron2/data/dataset_mapper.py", line 131, in __call__
annos, image_shape, mask_format=self.mask_format
File "/home/lzx/Amodal-Segmentation-Based-on-Visible-Region-Segmentation-and-Shape-Prior-main/detectron2/data/detection_utils.py", line 284, in annotations_to_instances
visible_masks = BitMasks(torch.stack([torch.from_numpy(x) for x in visible_masks]))
File "/home/lzx/Amodal-Segmentation-Based-on-Visible-Region-Segmentation-and-Shape-Prior-main/detectron2/data/detection_utils.py", line 284, in <listcomp>
visible_masks = BitMasks(torch.stack([torch.from_numpy(x) for x in visible_masks]))
ValueError: some of the strides of a given numpy array are negative. This is currently not supported, but will be added in future releases.
I've done some searches online but still get stuck.
Reference Link: https://discuss.pytorch.org/t/torch-from-numpy-not-support-negative-strides/3663
Can you give me some advice? Thanks a lot! ^_^
Thanks!
I suggest you to check the version of torch and numpy, especially the torch. Is it 1.4??
By the way, the torch package contains its own cuda, you can use torch.version.cuda to check whether it is the same as your own cuda vesion.
I remember that i met this error before. The reason is that i used wrong version of some packages.
I think may be the reason is that when you use pip install -r requirement.txt, you download torch==1.4.0 based on cuda 10.1.
But the cuda version in your computer maybe is 11.0 or 10.0??
Thank you for your replying.
After add .copy
, like:
visible_masks = BitMasks(torch.stack([torch.from_numpy(x.copy() for x in visible_masks]))
This error is gone now!
I'm running the training script now, and it's easy for deployment.
Again, thank you for your open-source code !