facebookresearch / facebookresearch/sam2

kernel crushed - runing on a jupyter with NVIDIA RTX 1070

Open
#245 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
19.9k
Forks
2.5k
PR merge metrics
No merged PRs in 30d

Description

**that is my code :**

import os
import sys
import cv2
import torch
import numpy as np
import base64
import random
from io import BytesIO
from PIL import Image
from flask import Flask, request, jsonify
from flask_cors import CORS
from pyngrok import ngrok
import threading
import traceback
import matplotlib.pyplot as plt
import subprocess
import io
import random

from sam2.build_sam import build_sam2
from sam2.sam2_image_predictor import SAM2ImagePredictor
from sam2.automatic_mask_generator import SAM2AutomaticMaskGenerator

HOME = os.getcwd()
print(HOME)

!git clone https://github.com/facebookresearch/segment-anything-2.git
%cd {HOME}/segment-anything-2
pip install -e . -q

if torch.cuda.is_available():
device = torch.device("cuda")
elif torch.backends.mps.is_available():
device = torch.device("mps")
else:
device = torch.device("cpu")
print(f"using device: {device}")

if device.type == "cuda":
torch.autocast("cuda", dtype=torch.bfloat16).__enter__()
if torch.cuda.get_device_properties(0).major >= 8:
torch.backends.cuda.matmul.allow_tf32 = True
torch.backends.cudnn.allow_tf32 = True
elif device.type == "mps":
print(
"\nSupport for MPS devices is preliminary. SAM 2 is trained with CUDA and might "
"give numerically different outputs and sometimes degraded performance on MPS. "
"See e.g. https://github.com/pytorch/pytorch/issues/84936 for a discussion."
)


DEVICE = device
CHECKPOINT = "/tf/Group502/sam2_hiera_tiny.pt"
CONFIG = "sam2_hiera_t.yaml"

sam2_model = build_sam2(CONFIG, CHECKPOINT, device=DEVICE, apply_postprocessing=False)

predictor = SAM2ImagePredictor(sam2_model)

**so after this line "predictor = SAM2ImagePredictor(sam2_model)" the kernel crushed, someone faced this issue ?**

would be appreciate any help !

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.