Skip to main content

Jupyter Notebook Use Case

{% embed url="https://www.youtube.com/watch?embeds_referring_euri=https://cdn.iframe.ly/&source_ve_path=Mjg2NjQsOTY3MTQ&v=IenVwz7iqfs" %}

  1. Create a GPU Container using Jupyter Notebook template

  2. Pulling YOLOv8 model using terminal in Jupyter Notebook

Step 1: Setup environment to run YOLO models, in this lab, we will use YOLOv8 to detect type of animals

!pip install ultralytics 
!apt update && apt install -y libglib2.0-0 libgl1 

Step 2: Install YOLOv8

from ultralytics import YOLO  
import cv2
import matplotlib.pyplot as plt
import torch
model = YOLO("yolov8l.pt")

Step 3: Load model into NVIDIA GPU H100 then check whether the model is using correct GPU

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")

Step 4: Object detecting using YOLOv8: load an image of some animals into the current workspace, run command below to detect the type of animals in the picture

{% hint style="info" %} Notice: the picture "640px-MountainLion.jpg" in this demo is pushed from local, please upload your own image and replace into the img_path before running {% endhint %}

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()

Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the ask query parameter:

GET https://ai-docs.fptcloud.com/fpt-gpu-cloud/gpu-container/use-cases/jupyter-notebook-use-case.md?ask=<question>

The question should be specific, self-contained, and written in natural language. The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.