You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Tutorial: Generate images using serverless GPUs in Azure Container Apps
15
16
16
17
In this article, you learn how to create a container app that uses [serverless GPUs](gpu-serverless-overview.md) to power an AI application.
17
18
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.
19
20
20
21
In this tutorial you:
21
22
@@ -28,12 +29,27 @@ In this tutorial you:
28
29
29
30
## Prerequisites
30
31
32
+
::: zone pivot="azure-portal"
33
+
31
34
| Resource | Description |
32
35
|---|---|
33
36
| 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. |
35
37
| 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). |
36
38
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
+
37
53
## Create your container app
38
54
39
55
1. Go to the Azure portal and search for and select **Container Apps**.
@@ -53,7 +69,7 @@ In this tutorial you:
53
69
54
70
| Setting | Value |
55
71
|---|---|
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). |
In the *Create Container Apps environment* window, enter the following values:
@@ -75,9 +91,9 @@ In this tutorial you:
75
91
| Image type | Select **public**. |
76
92
| Registry login server | Enter **mcr.microsoft.com**. |
77
93
| 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**. |
79
95
| 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. |
81
97
82
98
Select **Next: Ingress >**.
83
99
@@ -105,9 +121,88 @@ From the *Overview* window, select the **Application Url** link to open the web
105
121
> - 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).
106
122
> - When there are multiple containers in your application, the first container gets access to the GPU.
107
123
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.
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
+
108
203
## Monitor your GPU
109
204
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:
111
206
112
207
1. Open your container app in the Azure portal.
113
208
@@ -117,7 +212,7 @@ Once you generate an image, use the following steps to view results of the GPU p
117
212
118
213
1. Select your container.
119
214
120
-
1. Select **Reconnect*.
215
+
1. Select **Reconnect**.
121
216
122
217
1. In the *Choose start up command* window, select **/bin/bash**, and select **Connect**.
123
218
@@ -129,6 +224,8 @@ The resources created in this tutorial have an effect on your Azure bill.
129
224
130
225
If you aren't going to use these services long-term, use the steps to remove everything created in this tutorial.
131
226
227
+
::: zone pivot="azure-portal"
228
+
132
229
1. In the Azure portal, search for and select **Resource Groups**.
133
230
134
231
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
0 commit comments