@@ -420,6 +420,7 @@ def pipeline(
420420 revision : Optional [str ] = None ,
421421 use_fast : bool = True ,
422422 use_auth_token : Optional [Union [str , bool ]] = None ,
423+ device : Optional [Union [int , str , "torch.device" ]] = None ,
423424 device_map = None ,
424425 torch_dtype = None ,
425426 trust_remote_code : Optional [bool ] = None ,
@@ -506,6 +507,9 @@ def pipeline(
506507 use_auth_token (`str` or *bool*, *optional*):
507508 The token to use as HTTP bearer authorization for remote files. If `True`, will use the token generated
508509 when running `transformers-cli login` (stored in `~/.huggingface`).
510+ device (`int` or `str` or `torch.device`):
511+ Sent directly as `model_kwargs` (just a simpler shortcut). Defines the device (*e.g.*, `"cpu"`, `"cuda:1"`,
512+ `"mps"`, or a GPU ordinal rank like `1`) on which this pipeline will be allocated.
509513 device_map (`str` or `Dict[str, Union[int, str, torch.device]`, *optional*):
510514 Sent directly as `model_kwargs` (just a simpler shortcut). When `accelerate` library is present, set
511515 `device_map="auto"` to compute the most optimized `device_map` automatically. [More
@@ -800,4 +804,4 @@ def pipeline(
800804 if feature_extractor is not None :
801805 kwargs ["feature_extractor" ] = feature_extractor
802806
803- return pipeline_class (model = model , framework = framework , task = task , ** kwargs )
807+ return pipeline_class (model = model , framework = framework , task = task , device = device , ** kwargs )
0 commit comments