All documents
This guide walks you through running an object detection model using YOLOv8 on Jupyter Notebook, from setup to inference
pip install ultralytics
apt update && apt install -y libglib2.0-0 libgl1
from ultralytics import YOLO
import cv2
import matplotlib.pyplot as plt
import torch
model = YOLO("yolov8l.pt")
model.to("cuda")
print("Model device:", model.device)
print("GPU available:", torch.cuda.is_available())
print("GPU name:", torch.cuda.get_device_name(0) if torch.cuda.is_available() else "No GPU")
print("Current device:", torch.cuda.current_device() if torch.cuda.is_available() else "None")
img_path = "640px-MountainLion.jpg"
results = model(img_path)
allocated = torch.cuda.memory_allocated() / 10242
reserved = torch.cuda.memory_reserved() / 10242
print(f"Memory allocated: {allocated:.2f} MB")
print(f"Memory reserved: {reserved:.2f} MB")
results[0].show()
Cookie | Duration | Description |
---|---|---|
cookielawinfo-checbox-analytics | 11 months | |
cookielawinfo-checbox-functional | 11 months | |
cookielawinfo-checbox-others | 11 months | |
cookielawinfo-checkbox-necessary | 11 months | |
cookielawinfo-checkbox-performance | 11 months | |
viewed_cookie_policy | 11 months |