Skip to content

Commit c797469

Browse files
authored
Merge pull request #296440 from craigshoemaker/aca/jason/gpu-tutorial
[Container Apps] Update: Serverless GPU tutorial (CLI)
2 parents 61f592b + 9562ff6 commit c797469

File tree

1 file changed

+117
-8
lines changed

1 file changed

+117
-8
lines changed

articles/container-apps/gpu-image-generation.md

Lines changed: 117 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@ ms.service: azure-container-apps
77
ms.custom:
88
- ignite-2024
99
ms.topic: how-to
10-
ms.date: 11/06/2024
10+
ms.date: 03/17/2025
1111
ms.author: cshoe
12+
zone_pivot_groups: container-apps-portal-or-cli
1213
---
1314

1415
# Tutorial: Generate images using serverless GPUs in Azure Container Apps
1516

1617
In this article, you learn how to create a container app that uses [serverless GPUs](gpu-serverless-overview.md) to power an AI application.
1718

18-
With serverless GPUs, you have direct access to GPU compute resources without having to do manual infrastructure configuration such as installing drivers. All you have to do is deploy your AI model's image.
19+
With serverless GPUs, you have direct access to GPU compute resources without having to do manual infrastructure configuration such as installing drivers. All you have to do is deploy your AI model's image.
1920

2021
In this tutorial you:
2122

@@ -28,12 +29,27 @@ In this tutorial you:
2829
2930
## Prerequisites
3031

32+
::: zone pivot="azure-portal"
33+
3134
| Resource | Description |
3235
|---|---|
3336
| Azure account | You need an Azure account with an active subscription. If you don't have one, you [can create one for free](https://azure.microsoft.com/free/). |
34-
| Azure Container Registry instance | You need an existing Azure Container Registry instance or the permissions to create one. |
3537
| Access to serverless GPUs | Access to GPUs is only available after you request GPU quotas. You can submit your GPU quota request via a [customer support case](/azure/azure-portal/supportability/how-to-create-azure-support-request). |
3638

39+
::: zone-end
40+
41+
::: zone pivot="azure-cli"
42+
43+
| Resource | Description |
44+
|---|---|
45+
| Azure account | You need an Azure account with an active subscription. If you don't have one, you [can create one for free](https://azure.microsoft.com/free/). |
46+
| Access to serverless GPUs | Access to GPUs is only available after you request GPU quotas. You can submit your GPU quota request via a [customer support case](/azure/azure-portal/supportability/how-to-create-azure-support-request). |
47+
| [Azure CLI](/cli/azure/install-azure-cli) | Install the [Azure CLI](/cli/azure/install-azure-cli) or upgrade to the latest version. |
48+
49+
::: zone-end
50+
51+
::: zone pivot="azure-portal"
52+
3753
## Create your container app
3854

3955
1. Go to the Azure portal and search for and select **Container Apps**.
@@ -53,7 +69,7 @@ In this tutorial you:
5369

5470
| Setting | Value |
5571
|---|---|
56-
| Region | Select **West US 3**. <br><br>For more supported regions, refer to [Using serverless GPUs in Azure](gpu-serverless-overview.md#supported-regions). |
72+
| Region | Select **Sweden Central**. <br><br>For more supported regions, refer to [Using serverless GPUs in Azure](gpu-serverless-overview.md#supported-regions). |
5773
| Container Apps environment | Select **Create new**. |
5874

5975
In the *Create Container Apps environment* window, enter the following values:
@@ -75,9 +91,9 @@ In this tutorial you:
7591
| Image type | Select **public**. |
7692
| Registry login server | Enter **mcr.microsoft.com**. |
7793
| Image and tag | Enter **k8se/gpu-quickstart:latest**. |
78-
| Workload profile | Select the option that begins with **Consumption - Up to 4**... |
94+
| Workload profile | Select **Consumption - Up to 4 vCPUs, 8 Gib memory**. |
7995
| GPU | Select the checkbox. |
80-
| GPU Type | Select the **T4** option and select the link to add the profile to your environment. |
96+
| GPU Type | Select **Consumption-GPU-NC8as-T4 - Up to 8 vCPUs, 56 GiB memory** and select the link to add the profile to your environment. |
8197

8298
Select **Next: Ingress >**.
8399

@@ -105,9 +121,88 @@ From the *Overview* window, select the **Application Url** link to open the web
105121
> - To achieve the best performance of your GPU apps, follow the steps to [improve cold start for your serverless GPUs](gpu-serverless-overview.md#improve-gpu-cold-start).
106122
> - When there are multiple containers in your application, the first container gets access to the GPU.
107123
124+
::: zone-end
125+
126+
::: zone pivot="azure-cli"
127+
128+
## Create environment variables
129+
130+
Define the following environment variables. Before running this command, replace the `<PLACEHOLDERS>` with your values.
131+
132+
```azurecli
133+
RESOURCE_GROUP="<RESOURCE_GROUP>"
134+
ENVIRONMENT_NAME="<ENVIRONMENT_NAME>"
135+
LOCATION="swedencentral"
136+
CONTAINER_APP_NAME="<CONTAINER_APP_NAME>"
137+
CONTAINER_IMAGE="mcr.microsoft.com/k8se/gpu-quickstart:latest"
138+
WORKLOAD_PROFILE_NAME="NC8as-T4"
139+
WORKLOAD_PROFILE_TYPE="Consumption-GPU-NC8as-T4"
140+
```
141+
142+
## Create your container app
143+
144+
1. Create the resource group to contain the resources you create in this tutorial. This command should output `Succeeded`.
145+
146+
```azurecli
147+
az group create \
148+
--name $RESOURCE_GROUP \
149+
--location $LOCATION \
150+
--query "properties.provisioningState"
151+
```
152+
153+
1. Create a Container Apps environment to host your container app. This command should output `Succeeded`.
154+
155+
```azurecli
156+
az containerapp env create \
157+
--name $ENVIRONMENT_NAME \
158+
--resource-group $RESOURCE_GROUP \
159+
--location "$LOCATION" \
160+
--query "properties.provisioningState"
161+
```
162+
163+
1. Add a workload profile to your environment.
164+
165+
```azurecli
166+
az containerapp env workload-profile add \
167+
--name $ENVIRONMENT_NAME \
168+
--resource-group $RESOURCE_GROUP \
169+
--workload-profile-name $WORKLOAD_PROFILE_NAME \
170+
--workload-profile-type $WORKLOAD_PROFILE_TYPE
171+
```
172+
173+
1. Create your container app.
174+
175+
```azurecli
176+
az containerapp create \
177+
--name $CONTAINER_APP_NAME \
178+
--resource-group $RESOURCE_GROUP \
179+
--environment $ENVIRONMENT_NAME \
180+
--image $CONTAINER_IMAGE \
181+
--target-port 80 \
182+
--ingress external \
183+
--cpu 8.0 \
184+
--memory 56.0Gi \
185+
--workload-profile-name $WORKLOAD_PROFILE_NAME \
186+
--query properties.configuration.ingress.fqdn
187+
```
188+
189+
This command outputs the application URL for your container app.
190+
191+
## Use your GPU app
192+
193+
Open the application URL for your container app in your browser. Note it can take up to five minutes for the container app to start up.
194+
195+
The Azure Container Apps with Serverless GPUs application lets you enter a prompt to generate an image. You can also simply select `Generate Image` to use the default prompt. In the next step, you view the results of the GPU processing.
196+
197+
> [!NOTE]
198+
> - To achieve the best performance of your GPU apps, follow the steps to [improve cold start for your serverless GPUs](gpu-serverless-overview.md#improve-gpu-cold-start).
199+
> - When there are multiple containers in your application, the first container gets access to the GPU.
200+
201+
::: zone-end
202+
108203
## Monitor your GPU
109204
110-
Once you generate an image, use the following steps to view results of the GPU processing:
205+
Once you generate an image, use the following steps to view the results of the GPU processing:
111206
112207
1. Open your container app in the Azure portal.
113208
@@ -117,7 +212,7 @@ Once you generate an image, use the following steps to view results of the GPU p
117212
118213
1. Select your container.
119214
120-
1. Select **Reconnect*.
215+
1. Select **Reconnect**.
121216
122217
1. In the *Choose start up command* window, select **/bin/bash**, and select **Connect**.
123218
@@ -129,6 +224,8 @@ The resources created in this tutorial have an effect on your Azure bill.
129224
130225
If you aren't going to use these services long-term, use the steps to remove everything created in this tutorial.
131226
227+
::: zone pivot="azure-portal"
228+
132229
1. In the Azure portal, search for and select **Resource Groups**.
133230
134231
1. Select **my-gpu-demo-group**.
@@ -139,6 +236,18 @@ If you aren't going to use these services long-term, use the steps to remove eve
139236
140237
1. Select **Delete**.
141238
239+
::: zone-end
240+
241+
::: zone pivot="azure-cli"
242+
243+
Run the following command.
244+
245+
```azurecli
246+
az group delete --name $RESOURCE_GROUP
247+
```
248+
249+
::: zone-end
250+
142251
## Next steps
143252

144253
> [!div class="nextstepaction"]

0 commit comments

Comments
 (0)