Skip to content

Update cpu check to have better warning #3757

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
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
9 changes: 4 additions & 5 deletions composer/callbacks/memory_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,11 @@ def __init__(
self.memory_keys = memory_keys
self.dist_aggregate_batch_interval = dist_aggregate_batch_interval

def init(self, state: State, logger: Logger) -> None:
def after_load(self, state: State, logger: Logger) -> None:
# Not relying on `torch.cuda.is_available()` since the model could be on CPU.
model_device = next(state.model.parameters()).device

if model_device.type not in ('cuda', 'meta'):
warnings.warn(f'The memory monitor only works on CUDA devices, but the model is on {model_device.type}.')
devices = {p.device.type for p in state.model.parameters()}
if 'cuda' not in devices and 'meta' not in devices:
warnings.warn(f'The memory monitor only works on CUDA devices, but the model is on {devices}.')

def after_train_batch(self, state: State, logger: Logger):
memory_report = {}
Expand Down
Loading