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

kwarg fp16 doesn't exist anymore in Accelerate, replaced with mixed_precision #1450

Closed
wants to merge 5 commits into from
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
4 changes: 2 additions & 2 deletions catalyst/engines/torch.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ def __init__(self, *args, **kwargs) -> None:
"""Init."""
super().__init__(*args, cpu=False, **kwargs)

def prepare_model(self, model):
def prepare_model(self, model, *args, **kwargs):
"""Overrides."""
model = torch.nn.DataParallel(model)
model = super().prepare_model(model)
model = super().prepare_model(model, *args, **kwargs)
return model


Expand Down
6 changes: 4 additions & 2 deletions catalyst/runners/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,10 @@ def train(
.. _`minimal examples`: https://github.com/catalyst-team/catalyst#minimal-examples # noqa: E501, W505

"""
mixed_precision = 'fp16' if fp16 else 'no'
# experiment setup
self._engine = (
engine or self.engine or get_available_engine(cpu=cpu, fp16=fp16, ddp=ddp)
engine or self.engine or get_available_engine(cpu=cpu, mixed_precision=mixed_precision, ddp=ddp)
)
# self._trial = trial
self._loggers = loggers
Expand Down Expand Up @@ -428,7 +429,8 @@ def predict_loader(

.. _`minimal examples`: https://github.com/catalyst-team/catalyst#minimal-examples # noqa: E501, W505
"""
self.engine = engine or get_available_engine(cpu=cpu, fp16=fp16)
mixed_precision = 'fp16' if fp16 else 'no'
self.engine = engine or get_available_engine(cpu=cpu, mixed_precision=mixed_precision)

if model is not None:
self.model = model
Expand Down
10 changes: 5 additions & 5 deletions catalyst/utils/torch.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ def get_device() -> torch.device:

def get_available_engine(
cpu: bool = False,
fp16: bool = False,
mixed_precision: str = 'no',
ddp: bool = False,
) -> "Engine":
"""Returns available engine based on given arguments.

Args:
cpu (bool): option to use cpu for training. Default is `False`.
ddp (bool): option to use DDP for training. Default is `False`.
fp16 (bool): option to use APEX for training. Default is `False`.
mixed_precision (str): whether or not to use mixed precision training. Default is `no`.

Returns:
Engine which match requirements.
Expand All @@ -120,11 +120,11 @@ def get_available_engine(
is_multiple_gpus = torch.cuda.device_count() > 1
if is_multiple_gpus:
if ddp:
return DistributedDataParallelEngine(fp16=fp16)
return DistributedDataParallelEngine(mixed_precision=mixed_precision)
else:
return DataParallelEngine(fp16=fp16)
return DataParallelEngine(mixed_precision=mixed_precision)
else:
return GPUEngine(fp16=fp16)
return GPUEngine(mixed_precision=mixed_precision)


def get_available_gpus():
Expand Down
2 changes: 1 addition & 1 deletion requirements/requirements-cv.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
imageio>=2.5.0
opencv-python-headless>=4.2.0.32
scikit-image<0.19.0>=0.16.1
scikit-image<0.19.0,>=0.16.1
torchvision>=0.5.0
Pillow>=6.1 # torchvision fix (https://github.com/python-pillow/Pillow/issues/4130)
requests