Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions vae/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ The main.py script accepts the following arguments:
optional arguments:
--batch-size input batch size for training (default: 128)
--epochs number of epochs to train (default: 10)
--no-cuda enables CUDA training
--mps enables GPU on macOS
--no-cuda disables CUDA training
--no-mps disables GPU on macOS
--no-xpu disables XPU training in Intel GPUs
--seed random seed (default: 1)
--log-interval how many batches to wait before logging training status
```
```
11 changes: 9 additions & 2 deletions vae/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,34 @@
help='input batch size for training (default: 128)')
parser.add_argument('--epochs', type=int, default=10, metavar='N',
help='number of epochs to train (default: 10)')
parser.add_argument('--no-cuda', action='store_true', default=False,
parser.add_argument('--no-cuda', action='store_true',
help='disables CUDA training')
parser.add_argument('--no-mps', action='store_true', default=False,
parser.add_argument('--no-mps', action='store_true',
help='disables macOS GPU training')
parser.add_argument('--no-xpu', action='store_true',
help='disables Intel XPU training')
parser.add_argument('--seed', type=int, default=1, metavar='S',
help='random seed (default: 1)')
parser.add_argument('--log-interval', type=int, default=10, metavar='N',
help='how many batches to wait before logging training status')
args = parser.parse_args()
args.cuda = not args.no_cuda and torch.cuda.is_available()
use_mps = not args.no_mps and torch.backends.mps.is_available()
use_xpu = not args.no_xpu and torch.xpu.is_available()

torch.manual_seed(args.seed)

if args.cuda:
device = torch.device("cuda")
elif use_mps:
device = torch.device("mps")
elif use_xpu:
device = torch.device("xpu")
else:
device = torch.device("cpu")

print('Device to use: ', device)

kwargs = {'num_workers': 1, 'pin_memory': True} if args.cuda else {}
train_loader = torch.utils.data.DataLoader(
datasets.MNIST('../data', train=True, download=True,
Expand Down