Skip to content

Instantly share code, notes, and snippets.

@shunting314
Created December 30, 2025 20:19
Show Gist options
  • Select an option

  • Save shunting314/3591753fa78f2c8faf259c65f21f265b to your computer and use it in GitHub Desktop.

Select an option

Save shunting314/3591753fa78f2c8faf259c65f21f265b to your computer and use it in GitHub Desktop.
import torch
import json
N = 2 ** 28
glist = []
mempool = torch.cuda.graph_pool_handle()
for _ in range(3):
g = torch.cuda.CUDAGraph()
glist.append(g)
with torch.cuda.graph(g, pool=mempool):
x = torch.randn(N, device="cuda")
del x
print(g.pool())
print(json.dumps(torch.cuda.memory_snapshot(), indent=2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment