Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Cette page explique comment exécuter votre pipeline Dataflow à l'aide du type de GPU NVIDIA® L4.
Le type de GPU L4 est utile pour exécuter des pipelines d'inférence de machine learning.
Conditions requises
Utilisez le SDK Apache Beam version 2.46 ou ultérieure. Apache Beam 2.50 ou version ultérieure est recommandé.
Vous avez besoin d'un quota de GPU L4 (NVIDIA_L4_GPUS) dans la région dans laquelle votre job s'exécute.
Pour en savoir plus, consultez la page Quotas de GPU.
Le type de GPU L4 n'est disponible qu'avec le type de machine optimisé pour l'accélérateur G2.
Pour plus d'informations, consultez la série de machines G2.
Les pipelines qui utilisent le type de GPU L4 sont soumis aux limites standards de G2.
Le type de GPU NVIDIA L4 utilise la version 525.0 ou ultérieure du pilote NVIDIA et la version 12.0 ou ultérieure de CUDA Toolkit. Tout code utilisé dans votre pipeline doit être compatible avec la version du pilote NVIDIA et la version de CUDA Toolkit. Par exemple, si vous utilisez PyTorch, vous devez utiliser PyTorch 23.01 ou une version ultérieure.
Exécuter des pipelines avec le type de GPU NVIDIA® L4
Pour utiliser le type de GPU NVIDIA L4, vous devez inclure les options de pipeline et les options de service suivantes dans le code de votre pipeline.
GPU_COUNT : nombre de GPU à utiliser. Chaque type de machine G2 dispose d'un nombre fixe de GPU NVIDIA L4. Pour connaître le nombre approprié de GPU pour votre type de machine, consultez la colonne Nombre de GPU dans le tableau Types de machines standards G2.
L'exemple Dockerfile suivant contient des dépendances compatibles pour un pipeline utilisant le type de GPU NVIDIA L4.
RUN apt-get -y update
RUN apt-get install [system packages]
# Install the SDK.
RUN pip install --no-cache-dir apache-beam[gcp]==2.51.0
# Install the machine learning dependencies.
RUN pip install --no-cache-dir tensorflow[and-cuda]
RUN pip install xgboost
RUN pip install transformers accelerate
(etc…..)
# Verify that the image doesn't have conflicting dependencies.
RUN pip check
# Copy files from official SDK image, including the script and dependencies.
COPY --from=apache/beam_python3.10_sdk:2.51.0 /opt/apache/beam /opt/apache/beam
# Set the entrypoint to Apache Beam SDK launcher.
ENTRYPOINT ["/opt/apache/beam/boot"]
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/04 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/09/04 (UTC)."],[[["\u003cp\u003eDataflow jobs using GPUs, like the NVIDIA L4, will incur charges as specified on the Dataflow pricing page and must use Dataflow Runner v2.\u003c/p\u003e\n"],["\u003cp\u003eTo utilize the NVIDIA L4 GPU type, Dataflow pipelines must use Apache Beam SDK version 2.46 or later, with 2.50 or later being recommended, and have the necessary L4 GPU quota.\u003c/p\u003e\n"],["\u003cp\u003eThe L4 GPU type is exclusive to the G2 accelerator-optimized machine type, and pipelines using it are subject to G2 standard limitations, which requires specification of the machine type and GPU count in pipeline options.\u003c/p\u003e\n"],["\u003cp\u003ePipelines using the NVIDIA L4 GPU type must be compatible with NVIDIA driver version 525.0 or later and CUDA toolkit version 12.0 or later, which can be ensured by using a custom container to manage dependencies.\u003c/p\u003e\n"],["\u003cp\u003eThe NVIDIA L4 GPU type is ideal for running machine learning inference pipelines on Dataflow, and a dockerfile is provided for users to implement it.\u003c/p\u003e\n"]]],[],null,["# Use the NVIDIA® L4 GPU type\n\n\u003cbr /\u003e\n\n| **Note:** The following considerations apply to this GA offering:\n|\n| - Jobs that use GPUs incur charges as specified in the Dataflow [pricing page](/dataflow/pricing).\n| - To use GPUs, your Dataflow job must use [Dataflow Runner v2](/dataflow/docs/runner-v2).\n\n\u003cbr /\u003e\n\nThe page explains how to run your Dataflow pipeline with the NVIDIA® L4 GPU type.\nThe L4 GPU type is useful for running machine learning inference pipelines.\n\nRequirements\n------------\n\n- Use the Apache Beam SDK version 2.46 or later. Apache Beam 2.50 or later is recommended.\n- You need L4 GPU quota (`NVIDIA_L4_GPUS`) in the region that your job runs in. For more information, see [GPU quotas](/compute/resource-usage#gpu_quota).\n- The L4 GPU type is available only with the G2 accelerator-optimized machine type. For more information, see [The G2 machine series](/compute/docs/accelerator-optimized-machines#g2-vms). Pipelines that use the L4 GPU type are subject to the [G2 standard limitations](/compute/docs/accelerator-optimized-machines#g2_standard_limitations).\n- The NVIDIA L4 GPU type uses the NVIDIA driver version 525.0 or later and the [CUDA toolkit](https://developer.nvidia.com/cuda-toolkit) version 12.0 or later. Any code that you use in your pipeline must be compatible with the NVIDIA driver version and CUDA toolkit version. For example, if you use PyTorch, you need to use PyTorch version 23.01 or later.\n\nRun pipelines with the NVIDIA® L4 GPU type\n------------------------------------------\n\nTo use the NVIDIA L4 GPU type, you need to include the following\n[pipeline options](/dataflow/docs/reference/pipeline-options) and\n[service options](/dataflow/docs/reference/service-options)\nin your pipeline code. \n\n### Java\n\n --workerMachineType=\u003cvar translate=\"no\"\u003eG2_MACHINE_TYPE\u003c/var\u003e\n --dataflowServiceOptions=\"worker_accelerator=type:nvidia-l4;count:\u003cvar translate=\"no\"\u003eGPU_COUNT\u003c/var\u003e;install-nvidia-driver\"\n\n### Python\n\n --machine_type=\u003cvar translate=\"no\"\u003eG2_MACHINE_TYPE\u003c/var\u003e\n --dataflow_service_options=\"worker_accelerator=type:nvidia-l4;count:\u003cvar translate=\"no\"\u003eGPU_COUNT\u003c/var\u003e;install-nvidia-driver\"\n\n### Go\n\n --worker_machine_type=\u003cvar translate=\"no\"\u003eG2_MACHINE_TYPE\u003c/var\u003e\n --dataflow_service_options=\"worker_accelerator=type:nvidia-l4;count:\u003cvar translate=\"no\"\u003eGPU_COUNT\u003c/var\u003e;install-nvidia-driver\"\n\nReplace the following values:\n\n- \u003cvar translate=\"no\"\u003eG2_MACHINE_TYPE\u003c/var\u003e: the [G2 machine type](/compute/docs/accelerator-optimized-machines#g2-standard-vms) to use\n- \u003cvar translate=\"no\"\u003eGPU_COUNT\u003c/var\u003e: The number of GPUs to use. Each G2 machine type has a fixed number of NVIDIA L4 GPUs. To find the correct number of GPUs for your machine type, see the **GPU count** column in the [G2 standard machine types](/compute/docs/accelerator-optimized-machines#g2-standard-vms) table.\n\nFor more information about running pipelines with\nGPUs, see [Run a pipeline with GPUs](/dataflow/docs/gpu/use-gpus).\n\nManage dependencies\n-------------------\n\nTo manage dependencies, use a custom container.\nFor more information, see\n[Use custom containers in Dataflow](/dataflow/docs/guides/using-custom-containers).\n\nThe following Dockerfile example contains compatible\ndependencies for a pipeline that uses the NVIDIA L4 GPU type. \n\n RUN apt-get -y update\n RUN apt-get install [system packages]\n\n # Install the SDK.\n RUN pip install --no-cache-dir apache-beam[gcp]==2.51.0\n # Install the machine learning dependencies.\n RUN pip install --no-cache-dir tensorflow[and-cuda]\n RUN pip install xgboost\n RUN pip install transformers accelerate\n (etc.....)\n # Verify that the image doesn't have conflicting dependencies.\n RUN pip check\n\n # Copy files from official SDK image, including the script and dependencies.\n COPY --from=apache/beam_python3.10_sdk:2.51.0 /opt/apache/beam /opt/apache/beam\n\n # Set the entrypoint to Apache Beam SDK launcher.\n ENTRYPOINT [\"/opt/apache/beam/boot\"]\n\nWhat's next\n-----------\n\n- Read about [best practices for working with Dataflow GPUs](/dataflow/docs/gpu/develop-with-gpus).\n- [Run a pipeline with GPUs](/dataflow/docs/gpu/use-gpus).\n- Learn more about [Dataflow ML](/dataflow/docs/machine-learning)."]]