Jupyter Notebook Use Case
This guide walks you through running an object detection model using YOLOv8 on Jupyter Notebook, from setup to inference



Last updated
Was this helpful?
This guide walks you through running an object detection model using YOLOv8 on Jupyter Notebook, from setup to inference





Last updated
Was this helpful?
Was this helpful?
!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()