[docs] add xpu device check (#34684)
* add XPU path * use accelerate API * Update docs/source/en/tasks/semantic_segmentation.md Co-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com> * update more places with accelerate API --------- Co-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com>
This commit is contained in:
@@ -43,8 +43,9 @@ Let's see the pipeline in action. First, initialize the pipeline. If you don't p
|
||||
```python
|
||||
import torch
|
||||
from transformers import pipeline
|
||||
|
||||
DEVICE = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
||||
from accelerate.test_utils.testing import get_backend
|
||||
# automatically detects the underlying device type (CUDA, CPU, XPU, MPS, etc.)
|
||||
DEVICE, _, _ = get_backend()
|
||||
pipe = pipeline(task="image-feature-extraction", model_name="google/vit-base-patch16-384", device=DEVICE, pool=True)
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user