Skip to content

Conversation

@JacoCronje
Copy link

What this does

Fixes cv2.imshow from hanging on Ubuntu. The code makes sure to initialize the opencv UI before torchvision gets imported.
torchvision is dependant on PyAV, which seems to be the root cause of the issue. If av gets imported before cv2, it clashes with the opencv UI and creates the hanging effect. torchvision imports av.

More information here: pytorch/vision#5940

How it was tested

After the code change, no more freezing for me. I'm running Ubuntu 22.04.4 LTS

@apockill
Copy link
Contributor

Also worth noting that the root cause of this issue is ffmpeg versions being mismatched from what pypi's pyav is expecting. The fix for this is to have the correct ffmpeg dependencies, as demonstrated in this docker environment I put together and tested for lerobot.

#519

@ivelin
Copy link
Contributor

ivelin commented Feb 26, 2025

This would be a great fix. I had to reinstall the whole opencv stack and nvda dependencies as a workaround.

@imstevenpmwork
Copy link
Collaborator

Related to #679

@imstevenpmwork imstevenpmwork added the bug Something isn’t working correctly label Mar 4, 2025
@Ke-Wang1017
Copy link
Contributor

This simple fix works like magic

xuaner233 pushed a commit to xuaner233/lerobot that referenced this pull request Mar 7, 2025
xuaner233 pushed a commit to xuaner233/lerobot that referenced this pull request Mar 10, 2025
xuaner233 pushed a commit to xuaner233/lerobot that referenced this pull request Mar 10, 2025
@frk2
Copy link

frk2 commented Mar 21, 2025

Just confirming this works for me too! Thanks !

@imstevenpmwork
Copy link
Collaborator

Hello @JacoCronje, thanks for your contribution. I'm closing this PR as this was addressed in: #903

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn’t working correctly

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants