Error opening .ncu-rep files

I get the following error when I try to open a .ncu-rep file that I generated from the command:

#!/bin/bash

batch_sizes=(64)
input_script="inference_scripts/yolo_infer.py"
output_dir="results/ncu-reps/9-April/yolo"

echo "$input_script"

script_name=$(basename "$input_script" .py)
for batch_size in "${batch_sizes[@]}"; do
    sudo ncu --target-processes all --set roofline -f -o "$output_dir/${script_name}_bs_${batch_size}_epoch_20" bash exp_script.sh "$input_script" "$batch_size"
    echo "Profiling for batch size $batch_size successful!"
done
echo "PROFILING SUCCESSFUL!"

where yolo_infer.py program is as follows:

import numpy as np
from ultralytics import YOLO
import argparse
import torch
from warnings import filterwarnings
import logging
import os

filterwarnings('ignore')

parser = argparse.ArgumentParser()
parser.add_argument('--epochs', default=20, type=int)
parser.add_argument('--batch_size', default=32, type=int)
args = parser.parse_args()

epochs = args.epochs
batch_size = args.batch_size

# Set up logging
log_filename = f'yolo_epochs_{epochs}_batchsize_{batch_size}.log'
logging.basicConfig(filename=log_filename, level=logging.INFO, format='%(asctime)s - %(message)s')

# Load the YOLOv8 model (pre-trained on COCO dataset)
model = YOLO('yolov8n.pt')  # Use 'yolov8n.pt' for a small model; adjust as needed.
model.to('cuda')

# Function to generate random images
def generate_random_images(bs=16, width=640, height=640):
    images = np.array([np.random.randint(0, 256, (height, width, 3), dtype=np.uint8)
                       for _ in range(bs)])
    return torch.tensor(images).permute(0, 3, 1, 2).float().cuda()

# Perform inference using YOLOv8
def perform_inference(model, images):
    results = []
    for idx, img in enumerate(images):
        # YOLOv8 requires images in BGR format (OpenCV)
        result = model.predict(img, conf=0.25, verbose=False)  # Set confidence threshold as needed
        results.append(result)
    return results

# Perform inference
for i in range(epochs):
    random_images = generate_random_images(bs=batch_size)
    print(random_images.shape)
    inference_results = perform_inference(model, random_images)
    logging.info(f'Epoch {i+1}/{epochs} completed')
    # print(inference_results)

I am able to get the results for batch size 1. But for batch size 2 my .ncu-rep file is surprisingly of 15GB and does not open in Nvidia Nsight Compute software.

Try using the same version of ncu-ui to open the report that you used to collect it.

The UI does not scale to arbitrary report sizes. You can import the report into the ncu command line interface with -i and adjust the output to inspect the results.

In general, collecting 15GB reports is not meaningful and means you didn’t filter the kernels or ranges to profile appropriately. Use Nsight Systems to determine your bottleneck and use the collection filters of ncu to collect only data for these.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.