Skip to content

Instantly share code, notes, and snippets.

View Jack47's full-sized avatar
🎯
Focusing

Jack Chen Jack47

🎯
Focusing
View GitHub Profile
@mcarilli
mcarilli / nsight.sh
Last active July 19, 2024 09:31
Favorite nsight systems profiling commands for Pytorch scripts
# This isn't supposed to run as a bash script, i named it with ".sh" for syntax highlighting.
# https://developer.nvidia.com/nsight-systems
# https://docs.nvidia.com/nsight-systems/profiling/index.html
# My preferred nsys (command line executable used to create profiles) commands
#
# In your script, write
# torch.cuda.nvtx.range_push("region name")
# ...
import matplotlib.pyplot as plt
from matplotlib.patches import Rectangle
import numpy
import random
def plot_memory_events(AllocFreeEvents, device, file_name = 'memory_events.pdf', alloc_free_seq_lengths = [], num_events=0, distance=int(1e6)):
events_for_device = AllocFreeEvents[device]
if num_events <=0:
num_events = len(events_for_device)