-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix amp/apex misconfiguration error for cpu (#6107)
* fix weird test * fix apex plugin test * fix raise * cpu test * fix type * add changelog
- Loading branch information
Showing
5 changed files
with
40 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from unittest.mock import Mock | ||
|
||
import pytest | ||
import torch | ||
|
||
from pytorch_lightning.accelerators import CPUAccelerator | ||
from pytorch_lightning.plugins import SingleDevicePlugin | ||
from pytorch_lightning.plugins.precision import MixedPrecisionPlugin | ||
from pytorch_lightning.utilities.exceptions import MisconfigurationException | ||
|
||
|
||
def test_unsupported_precision_plugins(): | ||
""" Test error messages are raised for unsupported precision plugins with CPU. """ | ||
trainer = Mock() | ||
model = Mock() | ||
accelerator = CPUAccelerator( | ||
training_type_plugin=SingleDevicePlugin(torch.device("cpu")), | ||
precision_plugin=MixedPrecisionPlugin() | ||
) | ||
with pytest.raises(MisconfigurationException, match=r"amp \+ cpu is not supported."): | ||
accelerator.setup(trainer=trainer, model=model) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters