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

Segmentation fault when using torch together with decord #324

Open
xiaosu-zhu opened this issue Oct 30, 2024 · 2 comments
Open

Segmentation fault when using torch together with decord #324

xiaosu-zhu opened this issue Oct 30, 2024 · 2 comments

Comments

@xiaosu-zhu
Copy link

xiaosu-zhu commented Oct 30, 2024

EDIT: The root cause of Segmentation fault is from torch, not cv2, please see the correction below.

I have installed opencv-python-headless and decord together. The version info is listed below.

opencv-python-headless 4.10.0.84
decord 0.6.0

I try to import two libs in a python script:

import cv2
import decord

OR 

import decord
import cv2

No matter which order I import two libs, both of them lead to Segmentation fault (core dumped) crash, without any other logs.

@JonathanLi19
Copy link

Same problem here

@xiaosu-zhu
Copy link
Author

Correction

I have made a several test and found the core problem is from torch cuda. You could try several snippets below:

import torch
from decord import VideoReader

vr = VideoReader(video_path)
a = torch.tensor([3], device='cuda')

---
Segmentation fault (core dumped)
import torch
from decord import VideoReader

a = torch.tensor([3], device='cuda')
vr = VideoReader(video_path)

---
Segmentation fault (core dumped)
import torch
a = torch.tensor([3], device='cuda')

from decord import VideoReader

vr = VideoReader(video_path)

---
NORMAL

I found when creating a cuda tensor DIRECTLY AFTER torch import and then import the decord, all things will be fine.

If you import decord ahead and create any cuda tensor, a Segmentation fault will immediately throw out.

@xiaosu-zhu xiaosu-zhu changed the title Segmentation fault when using cv2 together with decord Segmentation fault when using torch together with decord Oct 30, 2024
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

2 participants