Exécuter des jobs d'entraînement personnalisés sur une ressource persistante
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Cette page explique comment exécuter un job d'entraînement personnalisé sur une ressource persistante à l'aide de Google Cloud CLI, du SDK Vertex AI pour Python et de l'API REST.
Normalement, lorsque vous créez un job d'entraînement personnalisé, vous devez spécifier les ressources de calcul que le job créée et sur lesquelles il s'exécute. Une fois que vous avez créé une ressource persistante, vous pouvez configurer le job d'entraînement personnalisé pour qu'il s'exécute sur un ou plusieurs pools de ressources de cette ressource persistante. L'exécution d'un job d'entraînement personnalisé sur une ressource persistante réduit de manière significative le temps de démarrage habituellement nécessaire à la création de la ressource de calcul.
Rôles requis
Pour obtenir l'autorisation dont vous avez besoin pour exécuter des jobs d'entraînement personnalisés sur une ressource persistante, demandez à votre administrateur de vous accorder le rôle IAM Utilisateur Vertex AI (roles/aiplatform.user) sur votre projet.
Pour en savoir plus sur l'attribution de rôles, consultez la page Gérer l'accès aux projets, aux dossiers et aux organisations.
Ce rôle prédéfini contient l'autorisation aiplatform.customJobs.create, qui est requise pour exécuter des jobs d'entraînement personnalisés sur une ressource persistante.
Créer un job d'entraînement qui s'exécute sur une ressource persistante
Pour créer un job d'entraînement personnalisé qui s'exécute sur une ressource persistante, apportez les modifications suivantes aux instructions standards de la section créer un job d'entraînement personnalisé :
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 2024/12/19 (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 2024/12/19 (UTC)."],[],[],null,["# Run custom training jobs on a persistent resource\n\nThis page shows you how to run a custom training job on a persistent resource by\nusing the Google Cloud CLI, Vertex AI SDK for Python, and the REST API.\n\nNormally, when you\n[create a custom training job](/vertex-ai/docs/training/create-custom-job), you need to\nspecify compute resources that the job creates and runs on. After you create a\npersistent resource, you can instead configure the custom training job to run on\none or more resource pools of that persistent resource. Running a custom\ntraining job on a persistent resource significantly reduces the job startup time\nthat's otherwise needed for compute resource creation.\n\nRequired roles\n--------------\n\n\nTo get the permission that\nyou need to run custom training jobs on a persistent resource,\n\nask your administrator to grant you the\n\n\n[Vertex AI User](/iam/docs/roles-permissions/aiplatform#aiplatform.user) (`roles/aiplatform.user`)\nIAM role on your project.\n\n\nFor more information about granting roles, see [Manage access to projects, folders, and organizations](/iam/docs/granting-changing-revoking-access).\n\n\nThis predefined role contains the\n` aiplatform.customJobs.create`\npermission,\nwhich is required to\nrun custom training jobs on a persistent resource.\n\n\nYou might also be able to get\nthis permission\nwith [custom roles](/iam/docs/creating-custom-roles) or\nother [predefined roles](/iam/docs/roles-overview#predefined).\n\nCreate a training job that runs on a persistent resource\n--------------------------------------------------------\n\nTo create a custom training jobs that runs on a persistent resource, make the\nfollowing modifications to the standard instructions for\n[creating a custom training job](/vertex-ai/docs/training/create-custom-job): \n\n### gcloud\n\n- Specify the `--persistent-resource-id` flag and set the value to the ID of the persistent resource (\u003cvar translate=\"no\"\u003ePERSISTENT_RESOURCE_ID\u003c/var\u003e) that you want to use.\n- Specify the `--worker-pool-spec` flag such that the values for `machine-type` and `disk-type` matches exactly with a corresponding resource pool from the persistent resource. Specify one `--worker-pool-spec` for single node training and multiple for distributed training.\n- Specify a `replica-count` less than or equal to the `replica-count` or `max-replica-count` of the corresponding resource pool.\n\n### Python\n\nTo learn how to install or update the Vertex AI SDK for Python, see [Install the Vertex AI SDK for Python](/vertex-ai/docs/start/use-vertex-ai-python-sdk).\n\nFor more information, see the\n[Python API reference documentation](/python/docs/reference/aiplatform/latest).\n\n def create_custom_job_on_persistent_resource_sample(\n project: str,\n location: str,\n staging_bucket: str,\n display_name: str,\n container_uri: str,\n persistent_resource_id: str,\n service_account: Optional[str] = None,\n ) -\u003e None:\n aiplatform.init(\n project=project, location=location, staging_bucket=staging_bucket\n )\n\n worker_pool_specs = [{\n \"machine_spec\": {\n \"machine_type\": \"n1-standard-4\",\n \"accelerator_type\": \"NVIDIA_TESLA_K80\",\n \"accelerator_count\": 1,\n },\n \"replica_count\": 1,\n \"container_spec\": {\n \"image_uri\": container_uri,\n \"command\": [],\n \"args\": [],\n },\n }]\n\n custom_job = aiplatform.CustomJob(\n display_name=display_name,\n worker_pool_specs=worker_pool_specs,\n persistent_resource_id=persistent_resource_id,\n )\n\n custom_job.run(service_account=service_account)\n\n### REST\n\n- Specify the `persistent_resource_id` parameter and set the value to the ID of the persistent resource (\u003cvar translate=\"no\"\u003ePERSISTENT_RESOURCE_ID\u003c/var\u003e) that you want to use.\n- Specify the `worker_pool_specs` parameter such that the values of `machine_spec` and `disk_spec` for each resource pool matches exactly with a corresponding resource pool from the persistent resource. Specify one `machine_spec` for single node training and multiple for distributed training.\n- Specify a `replica_count` less than or equal to the `replica_count` or `max_replica_count` of the corresponding resource pool, excluding the replica count of any other jobs running on that resource pool.\n\nWhat's next\n-----------\n\n- [Learn about persistent resource](/vertex-ai/docs/training/persistent-resource-overview).\n- [Create and use a persistent resource](/vertex-ai/docs/training/persistent-resource-create).\n- [Get information about a persistent resource](/vertex-ai/docs/training/persistent-resource-get).\n- [Reboot a persistent resource](/vertex-ai/docs/training/persistent-resource-reboot).\n- [Delete a persistent resource](/vertex-ai/docs/training/persistent-resource-delete)."]]