When training the neural network models based on PyTorch, the RTX5090(Stable 2.7.1 / Preview (Nightly) ) sometimes performs less efficiently than the RTX4090. The testing code is shown as follow. When testing the Big data, RTX5090 performs less efficiently than the RTX4090. But when testing the Small data, RTX5090 performs more efficiently than the RTX4090. I am confused by this phenomenon.
import torch
import torch.nn as nn
import torch.optim as optim
import time
#(1)Small data
# x = torch.rand((10000,3))
# y = torch.rand((10000,1))
#(2)Big data
x = torch.rand((100000,3))
y = torch.rand((100000,1))
class Net(nn.Module):
def __init__(self,):
super(Net, self).__init__()
self.fc1 = nn.Linear(3, 200)
self.fc2 = nn.Linear(200, 200)
self.fc3 = nn.Linear(200, 200)
self.fc4 = nn.Linear(200, 200)
self.fc5 = nn.Linear(200, 1)
def forward(self, x):
x = torch.sin(self.fc1(x))
x = torch.sin(self.fc2(x))
x = torch.sin(self.fc3(x))
x = torch.sin(self.fc4(x))
x = self.fc5(x)
return x
T1=time.time()
model = Net()
criterion = nn.MSELoss()
optimizer = optim.Adam(model.parameters(), lr=0.01)
for epoch in range(300):
optimizer.zero_grad()
outputs = model(x)
loss = criterion(outputs, y)
loss.backward()
optimizer.step()
if epoch % 100 == 0:
print(f'Epoch {epoch}, Loss: {loss.item():.4f}')
T2=time.time()
print(T2-T1)