# or any other option that preloads model onto device
try:
self.model.to(self.device)
exceptValueError:
eval_logger.debug(
"Failed to place model onto specified device. This may be because the model is quantized via `bitsandbytes` or `device_map` is provided. If the desired GPU is being used, this message is safe to ignore."
)
# place model onto device requested manually,
# if not using HF Accelerate or device_map
# or any other option that preloads model onto device
try:
self.model.to(self.device)
exceptValueError:
eval_logger.debug(
"Failed to place model onto specified device. This may be because the model is quantized via `bitsandbytes` or `device_map` is provided. If the desired GPU is being used, this message is safe to ignore."
)
# multigpu data-parallel support when launched with accelerate
ifgpus>1:
ifaccelerator.num_processes>1:
...
...
@@ -327,12 +327,12 @@ class HFLM(TemplateLM):
def_get_accelerate_args(
self,
parallelize:Optional[bool]=None,
device_map:Optional[str]="auto",
max_memory_per_gpu:Optional[Union[int,str]]=None,
max_cpu_memory:Optional[Union[int,str]]=None,
offload_folder:Optional[str]="./offload",
gpus:Optional[int]=None,
parallelize:bool|None=None,
device_map:str|None="auto",
max_memory_per_gpu:int|str|None=None,
max_cpu_memory:int|str|None=None,
offload_folder:str|None="./offload",
gpus:int|None=None,
)->dict:
"""Returns the kwargs needed to apply `accelerate` in `AutoModel.from_pretrained`."""