Skip to content

Instantly share code, notes, and snippets.

@rbocchinfuso
Created July 26, 2024 00:37
Show Gist options
  • Select an option

  • Save rbocchinfuso/f1e80a415a237675973c94bdc85bed89 to your computer and use it in GitHub Desktop.

Select an option

Save rbocchinfuso/f1e80a415a237675973c94bdc85bed89 to your computer and use it in GitHub Desktop.
Create GPU load with PyTorch
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