In this tutorial, we will introduce you how to fix pytorch_lightning.utilities.exceptions.MisconfigurationException: You requested GPUs: [0] But your machine only has: [].
This error looks like:
In our computer, we only install one gpu. However, our code is:
trainer = Trainer(max_epochs=100, gpus=1) trainer.fit(system)
The index of first gpu is 0, gups = 1, which means we will use second gpu.
In order to fix this error, we should set gpus = 0.
trainer = Trainer(max_epochs=100, gpus=0) trainer.fit(system)
From the documentation:
# default used by the Trainer (ie: train on CPU)
trainer = Trainer(gpus=None)
# equivalent
trainer = Trainer(gpus=0)
Also from the doc:
gpus=x has been deprecated in v1.7 and will be removed in v2.0. Please use accelerator=’gpu’ and devices=x instead.