@@ -422,6 +422,7 @@ def pipeline(
422422 revision : Optional [str ] = None ,
423423 use_fast : bool = True ,
424424 use_auth_token : Optional [Union [str , bool ]] = None ,
425+ device : Optional [Union [int , str , "torch.device" ]] = None ,
425426 device_map = None ,
426427 torch_dtype = None ,
427428 trust_remote_code : Optional [bool ] = None ,
@@ -508,6 +509,9 @@ def pipeline(
508509 use_auth_token (`str` or *bool*, *optional*):
509510 The token to use as HTTP bearer authorization for remote files. If `True`, will use the token generated
510511 when running `huggingface-cli login` (stored in `~/.huggingface`).
512+ device (`int` or `str` or `torch.device`):
513+ Sent directly as `model_kwargs` (just a simpler shortcut). Defines the device (*e.g.*, `"cpu"`, `"cuda:1"`,
514+ `"mps"`, or a GPU ordinal rank like `1`) on which this pipeline will be allocated.
511515 device_map (`str` or `Dict[str, Union[int, str, torch.device]`, *optional*):
512516 Sent directly as `model_kwargs` (just a simpler shortcut). When `accelerate` library is present, set
513517 `device_map="auto"` to compute the most optimized `device_map` automatically. [More
@@ -802,4 +806,4 @@ def pipeline(
802806 if feature_extractor is not None :
803807 kwargs ["feature_extractor" ] = feature_extractor
804808
805- return pipeline_class (model = model , framework = framework , task = task , ** kwargs )
809+ return pipeline_class (model = model , framework = framework , task = task , device = device , ** kwargs )
0 commit comments