osai-ai / tensor-stream

A library for real-time video stream decoding to CUDA memory
GNU Lesser General Public License v2.1
377 stars 44 forks source link

RuntimeError: CUDA error: an illegal memory access was encountered #23

Closed andreasHan closed 3 years ago

andreasHan commented 3 years ago

When i use some function which need allocate new cuda memory e.g. tensor.contiguous() ; torch.nn.functional.pad

Like following code:

reader = TensorStreamConverter(v_source)
reader.initialize(repeat_number=20)
reader.start()
frame_parameters = FrameParameters(
    width=0,
    height=0,
    crop_coords=(0, 0, 0, 0),
    resize_type=ResizeType["NEAREST"],
    pixel_format=FourCC['RGB24'],
    normalization=False
)
tensor = reader.param_read(frame_parameters)
tensor = tensor.permute((2, 0, 1).contiguous()

Then occurs this error:

tensor = tensor.permute(2, 0, 1).contiguous()
RuntimeError: CUDA error: an illegal memory access was encountered

But when i remove contiguous(), this error doesn't appear.

Thx~

BykadorovR commented 3 years ago

Hi @andreasHan, I think it's some Pytorch issue, tensor-stream creates tensors via C++ torch from_blob function, maybe Pytorch doesn't support contiguous() feature for tensors created this way?