Created
July 26, 2024 00:37
-
-
Save rbocchinfuso/f1e80a415a237675973c94bdc85bed89 to your computer and use it in GitHub Desktop.
Create GPU load with PyTorch
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 multiprocessing | |
| import torch | |
| from torchvision.models import efficientnet_b0 | |
| from pytorch_benchmark import benchmark | |
| def gpu(args): | |
| print(f"Starting workload on GPU{args}") | |
| model = efficientnet_b0().to(f"cuda:{args}") # Model device sets benchmarking device | |
| sample = torch.randn(8, 3, 224, 224) # (B, C, H, W) | |
| results = benchmark(model, sample, num_runs=1000) | |
| if __name__ == '__main__': | |
| for i in range(6): | |
| p = multiprocessing.Process(target=gpu, args=(i,)) | |
| p.start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment