Skip to content

Commit 7fefd0e

Browse files
Use strings for GPU config (#1066)
Co-authored-by: Charles Frye <charles@modal.com>
1 parent 2e59e1c commit 7fefd0e

File tree

16 files changed

+17
-18
lines changed

16 files changed

+17
-18
lines changed

06_gpu_and_ml/dreambooth/diffusers_lora_finetune.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,7 @@ class TrainConfig(SharedConfig):
265265

266266
@app.function(
267267
image=image,
268-
gpu=modal.gpu.A100( # fine-tuning is VRAM-heavy and requires a high-VRAM GPU
269-
count=1, size="80GB"
270-
),
268+
gpu="A100-80GB", # fine-tuning is VRAM-heavy and requires a high-VRAM GPU
271269
volumes={MODEL_DIR: volume}, # stores fine-tuned model
272270
timeout=1800, # 30 minutes
273271
secrets=[huggingface_secret]

06_gpu_and_ml/embeddings/text_embeddings_inference.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import modal
1616

17-
GPU_CONFIG = modal.gpu.A10G()
17+
GPU_CONFIG = "A10G"
1818
MODEL_ID = "BAAI/bge-base-en-v1.5"
1919
BATCH_SIZE = 32
2020
DOCKER_IMAGE = (

06_gpu_and_ml/embeddings/wikipedia/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# We first set out configuration variables for our script.
88
## Embedding Containers Configuration
99
GPU_CONCURRENCY = 100
10-
GPU_CONFIG = modal.gpu.A10G()
10+
GPU_CONFIG = "A10G"
1111
MODEL_ID = "BAAI/bge-small-en-v1.5"
1212
MODEL_SLUG = MODEL_ID.split("/")[-1]
1313
BATCH_SIZE = 512

06_gpu_and_ml/llm-serving/chat_with_pdf_vision.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def download_model():
158158

159159
@app.cls(
160160
image=model_image,
161-
gpu=modal.gpu.A100(size="80GB"),
161+
gpu="A100-80GB",
162162
container_idle_timeout=10 * MINUTES, # spin down when inactive
163163
volumes={"/vol/pdfs/": pdf_volume, CACHE_DIR: cache_volume},
164164
)

06_gpu_and_ml/llm-serving/trtllm_llama.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def download_model():
154154
# about two quadrillion per second on an H100 SXM.
155155

156156
N_GPUS = 1 # Heads up: this example has not yet been tested with multiple GPUs
157-
GPU_CONFIG = modal.gpu.H100(count=N_GPUS)
157+
GPU_CONFIG = f"H100:{N_GPUS}"
158158

159159
DTYPE = "float16" # format we download in, regular fp16
160160
QFORMAT = "fp8" # format we quantize the weights to

06_gpu_and_ml/llm-serving/vllm_inference.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989

9090
@app.function(
9191
image=vllm_image,
92-
gpu=modal.gpu.H100(count=N_GPU),
92+
gpu=f"H100:{N_GPU}",
9393
container_idle_timeout=5 * MINUTES,
9494
timeout=24 * HOURS,
9595
allow_concurrent_inputs=1000,

06_gpu_and_ml/llm-structured/jsonformer_generate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def download_model():
5858
# The generate function takes two arguments `prompt` and `json_schema`, where
5959
# `prompt` is used to describe the domain of your data (for example, "plants")
6060
# and the schema contains the JSON schema you want to populate.
61-
@app.function(gpu=modal.gpu.A10G(), image=image)
61+
@app.function(gpu="A10G", image=image)
6262
def generate(prompt: str, json_schema: dict[str, Any]) -> dict[str, Any]:
6363
from jsonformer import Jsonformer
6464
from transformers import AutoModelForCausalLM, AutoTokenizer

06_gpu_and_ml/llm-structured/outlines_generate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def import_model(model_name):
106106
# We specify that we want to use the Mistral-7B model, and then ask for a character, and we'll receive structured data with the right schema.
107107

108108

109-
@app.function(image=outlines_image, gpu=modal.gpu.A100(size="40GB"))
109+
@app.function(image=outlines_image, gpu="A100-40GB")
110110
def generate(
111111
prompt: str = "Amiri, a 53 year old warrior woman with a sword and leather armor.",
112112
):

06_gpu_and_ml/stable_diffusion/image_to_image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def download_models():
8989
snapshot_download("stabilityai/sdxl-turbo", ignore_patterns=ignore)
9090

9191

92-
@app.cls(gpu=modal.gpu.A10G(), container_idle_timeout=240)
92+
@app.cls(gpu="A10G", container_idle_timeout=240)
9393
class Model:
9494
@modal.enter()
9595
def enter(self):

06_gpu_and_ml/text-to-video/mochi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def download_model(revision="83359d26a7e2bbe200ecbfda8ebff850fd03b545"):
133133
OUTPUTS_PATH: outputs, # videos will be saved to a distributed volume
134134
MODEL_PATH: model,
135135
},
136-
gpu=modal.gpu.H100(count=1),
136+
gpu="H100",
137137
timeout=1 * HOURS,
138138
)
139139
class Mochi:

0 commit comments

Comments
 (0)