Skip to content

Commit

Permalink
[docs] no hard-coding cuda (#3270)
Browse files Browse the repository at this point in the history
* no hard-coding cuda

* Update docs/source/usage_guides/big_modeling.md

Co-authored-by: Zach Mueller <[email protected]>

* update device_type

---------

Co-authored-by: Zach Mueller <[email protected]>
  • Loading branch information
faaany and muellerzr authored Dec 11, 2024
1 parent cb8b7c6 commit 3e62fbb
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions docs/source/usage_guides/big_modeling.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ This tutorial will show you how to use Big Model Inference in Accelerate and the

## Accelerate

A typical workflow for loading a PyTorch model is shown below. `ModelClass` is a model that exceeds the GPU memory of your device (mps or cuda).
A typical workflow for loading a PyTorch model is shown below. `ModelClass` is a model that exceeds the GPU memory of your device (mps or cuda or xpu).

```py
import torch
Expand Down Expand Up @@ -64,7 +64,8 @@ Now that the model is fully dispatched, you can perform inference.

```py
input = torch.randn(2,3)
input = input.to("cuda")
device_type = next(iter(model.parameters())).device.type
input = input.to(device_type)
output = model(input)
```

Expand All @@ -91,7 +92,8 @@ model = load_checkpoint_and_dispatch(
)

input = torch.randn(2,3)
input = input.to("cuda")
device_type = next(iter(model.parameters())).device.type
input = input.to(device_type)
output = model(input)
```

Expand Down

0 comments on commit 3e62fbb

Please sign in to comment.