DataPsycho:

model = LinearRegressionModel(input_dim=1, output_dim=1)
optimizer = torch.optim.SGD(model.parameters(), lr=0.001)
device_gpu = get_device()

loss = train(model, device_gpu, inputs, labels, epochs=2000)



In this sequence, you first grab the parameters while they’re on the CPU and stick them in the optimizer. Then you move the model to GPU in train.
I would recommend to either create the optimizer in train or do the moving right after instantiation (the latter is what I’d do, personally).
Best regards
Thomas