Step 1:
Check if cuda is available, and if the user wants to enable it.
Save this into a config variable, e.g. args.device
Step 2: Write device agnostic code.
Use torch.tensor((1,2), device=args.device)
Use x = model().to(device=args.device)
That’s it!