Skip to content
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

fix single gpu case #217

Merged
merged 1 commit into from
Feb 22, 2024
Merged
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
10 changes: 5 additions & 5 deletions data_juicer/utils/model_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,8 @@ def move_to_cuda(model, rank):
f'Moving {module.__class__.__name__} to CUDA device {rank}')
module.to(f'cuda:{rank}')
# Optionally, verify the device assignment
logger.debug(f'{module.__class__.__name__} is on device '
f'{next(module.parameters()).device}')
logger.debug(
f'{module.__class__.__name__} is on device {module.device}')


def get_model(model_key=None, rank=None):
Expand All @@ -303,7 +303,7 @@ def get_model(model_key=None, rank=None):
f'{model_key} not found in MODEL_ZOO ({mp.current_process().name})'
)
MODEL_ZOO[model_key] = model_key()
if use_cuda():
rank = 0 if rank is None else rank
move_to_cuda(MODEL_ZOO[model_key], rank)
if use_cuda():
rank = 0 if rank is None else rank
move_to_cuda(MODEL_ZOO[model_key], rank)
return MODEL_ZOO[model_key]
Loading