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

Python Jupyter Interactive Kernel crashed when use cv2.imshow() #14

Closed
lovelyPuppies opened this issue Oct 17, 2024 · 1 comment
Closed

Comments

@lovelyPuppies
Copy link
Collaborator

lovelyPuppies commented Oct 17, 2024

Jupyter Kernel Crash During cv2.imshow()

  • Description: Python Jupyter Interactive Kernel crashed.

๐Ÿ“… Written at: 2024-10-17 20:45:56

When it Occurs

  • Happens when using cv2.imshow() after initializing PoseC3D models:

    import torch
    from pathlib import Path
    from pyskl.models import Recognizer3D, build_model
    from mmcv.runner import load_checkpoint
    
    pyskl_path: Path = Path.home() / "repo/intel-edge-academy-6/external/pyskl"
    pyskl_data_path: Path = pyskl_path / "data"
    
    checkpoint_path = (
        Path.home()
        / "repo/intel-edge-academy-6/external/pyskl/work_dirs/posec3d/x3d_shallow_ntu60_xsub/joint/best_top1_acc_epoch_24.pth"
    )
    
    checkpoint = torch.load(str(checkpoint_path), map_location="cuda")
    assert isinstance(checkpoint, dict)
    
    posec3d_model_config = execute_code_and_extract_variables(checkpoint["meta"]["config"])
    
    checkpoint_path = (
        pyskl_path
        / "work_dirs/posec3d/x3d_shallow_ntu60_xsub/joint/best_top1_acc_epoch_24.pth"
    )
    
    posec3d_model: Recognizer3D = build_model(posec3d_model_config["model"])
    
    load_checkpoint(posec3d_model, str(checkpoint_path), map_location="cuda")
    
    posec3d_model = torch.compile(model=posec3d_model)
    
    posec3d_model = posec3d_model.cuda().eval()

Output Behavior

  • In Jupyter Interactive Kernel:

    The Kernel crashed while executing code in the current cell or a previous cell.
    Please review the code in the cell(s) to identify a possible cause of the failure.
    Click here for more info.
    View Jupyter log for further details.
    
  • If run as an executable:

    <no message>
    

Root Cause

  • Using cv2.imshow() within Jupyter can cause kernel crashes due to compatibility or memory management issues between OpenCV and the Jupyter environment.

Workaround

  • Use from IPython.display import clear_output, display instead of cv2.imshow() to avoid crashes in Jupyter.

๐Ÿ›๏ธ Example: OpenVINO Monodepth Notebook Example

@lovelyPuppies
Copy link
Collaborator Author

lovelyPuppies commented Jan 12, 2025

์ด ๋ฌธ์ œ๋Š” ๋‹ค์Œ ์š”์ธ๋“ค์ด ๊ฒฐํ•ฉ๋˜์–ด ๋ฐœ์ƒํ•œ ๊ฒƒ์œผ๋กœ ๋ณด์ž„

  • VS Code์˜ Remote-SSH๋ฅผ ํ†ตํ•ด Jetson Nano์— ์ ‘์†.
  • Jupyter Notebook (IPython) ์‹คํ–‰.
  • ํ•˜๋“œ์›จ์–ด ๊ฐ€์†์„ ์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š” OpenCV ํ™œ์šฉ.

โžก๏ธ CPU ์‚ฌ์šฉ๋Ÿ‰ ์ฆ๊ฐ€ ๋ฐ ๋ฉ”๋ชจ๋ฆฌ ๋ถ€์กฑ ์ด ์›์ธ.

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