Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NumPy array not writable error in slowfast/datasets/decoder.py when using torchvision backend. "np.array" typecasting required #629

Open
alpargun opened this issue Dec 2, 2022 · 0 comments

Comments

@alpargun
Copy link

alpargun commented Dec 2, 2022

When using torchvision backend I receive the error:

/home/alp/Desktop/slowfast-with-torchvision/SlowFast/slowfast/datasets/decoder.py:273: UserWarning: The given NumPy array is not writable, and PyTorch does not support non-writable tensors. This means writing to this tensor will result in undefined behavior. You may want to copy the array to protect its data or make it writable before converting it to a tensor. This type of warning will be suppressed for the rest of this program. (Triggered internally at /opt/conda/conda-bld/pytorch_1666642991888/work/torch/csrc/utils/tensor_numpy.cpp:199.)

I am using

  • pytorch=1.13.0
  • torchvision=0.14.0
  • ffmpeg=4.2

In order to fix this problem, the line, should be fixed to:
video_tensor = torch.from_numpy(np.frombuffer(np.array(video_handle), dtype=np.uint8))

When I made the above change, I no longer receive the warning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant