Created
January 24, 2025 13:44
-
-
Save vmoens/2a681e2615e4e7e30c214a7b53996a9a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import time | |
| import torch | |
| DELAY = 100000000 | |
| with torch.profiler.profile( | |
| activities=[torch.profiler.ProfilerActivity.CPU, torch.profiler.ProfilerActivity.CUDA], | |
| record_shapes=True, | |
| profile_memory=True, | |
| #with_stack=True | |
| ) as p: | |
| x = torch.ones((1024, 1024),)# pin_memory=True) | |
| torch.cuda.synchronize() | |
| start = time.time() | |
| torch.cuda._sleep(DELAY) | |
| y1 = x.cuda(non_blocking=True) | |
| x.zero_() | |
| end = time.time() | |
| print("not corrupted:", (y1 == 1).all().item()) | |
| p.export_chrome_trace("profiling_results_pageable.json") | |
| with torch.profiler.profile( | |
| activities=[torch.profiler.ProfilerActivity.CPU, torch.profiler.ProfilerActivity.CUDA], | |
| record_shapes=True, | |
| profile_memory=True, | |
| #with_stack=True | |
| ) as p: | |
| x = torch.ones((1024, 1024), pin_memory=True) | |
| torch.cuda.synchronize() | |
| start = time.time() | |
| torch.cuda._sleep(DELAY) | |
| y1 = x.cuda(non_blocking=True) | |
| x.zero_() | |
| end = time.time() | |
| print("not corrupted:", (y1 == 1).all().item()) | |
| p.export_chrome_trace("profiling_results_pin.json") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment