-
-
Notifications
You must be signed in to change notification settings - Fork 4
Closed
Labels
good first issueGood for newcomersGood for newcomers
Description
Hi
Step 13.3. won't work if executed alone. I fixed the code adding the bold face lines.
Best,
Willfried
import time
import torch
matrix_size = 32*512
x = torch.randn(matrix_size, matrix_size)
y = torch.randn(matrix_size, matrix_size)
print("************* CPU SPEED *******************")
start = time.time()
result = torch.matmul(x, y)
print(time.time() - start)
print("verify device:", result.device)
if torch.cuda.is_available(): device = torch.device("cuda")
x_gpu = x.to(device)
y_gpu = y.to(device)
torch.cuda.synchronize()
for i in range(3):
print("************* GPU SPEED *******************")
start = time.time()
result_gpu = torch.matmul(x_gpu, y_gpu)
torch.cuda.synchronize()
print(time.time() - start)
print("verify device:", result_gpu.device)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
good first issueGood for newcomersGood for newcomers