AI开发平台MODELARTS-创建训练作业:请求示例

时间:2024-11-22 17:40:56

请求示例

  • 创建免费规格的训练作业。设置作业名称为“TestModelArtsJob”,描述为“This is a ModelArts job”。算法依赖的是id为3f5d6706-7b67-408d-8ba0-ec08048c45ed的算法,该算法未定义inputs与outputs,规格选用的是gpu免费规格。

    POST https://endpoint/v2/{project_id}/training-jobs
    
    {
      "kind" : "job",
      "metadata" : {
        "name" : "TestModelArtsJob",
        "description" : "This is a ModelArts job"
      },
      "algorithm" : {
        "id" : "3f5d6706-7b67-408d-8ba0-ec08048c45ed",
        "parameters" : [ {
          "name" : "input_dir",
          "value" : "obs://cn-north-4-rse/test/moxingtest-dir/"
        }, {
          "name" : "input_file",
          "value" : "obs://cn-north-4-rse/test/moxingtest/"
        }, {
          "name" : "large_file_method",
          "value" : "1"
        } ],
        "policies" : {
          "auto_search" : null
        },
        "environments" : { }
      },
      "spec" : {
        "resource" : {
          "flavor_id" : "modelarts.p3.large.public.free",
          "node_count" : 1
        },
        "log_export_path" : {
          "obs_url" : ""
        }
      }
    }
  • 使用 自定义镜像 创建训练作业。设置作业名称为“TestModelArtsJob2”,描述为“This is a ModelArts job2”的自定义镜像训练作业。使用专属资源池和nfs挂载。

    POST https://endpoint/v2/{project_id}/training-jobs
    
    {
      "kind" : "job",
      "metadata" : {
        "name" : "TestModelArtsJob2",
        "description" : "This is a ModelArts job2"
      },
      "algorithm" : {
        "engine" : {
          "image_url" : "xxxxxxxx/fastseq:1.2"
        },
        "command" : "cd /home/ma-user/ddp_demo && sh run_ddp.sh",
        "parameters" : [ ],
        "policies" : {
          "auto_search" : null
        },
        "environments" : {
          "NCCL_DEBUG" : "INFO",
          "NCCL_IB_DISABLE" : "0"
        }
      },
      "spec" : {
        "resource" : {
          "flavor_id" : "modelarts.pool.visual.xlarge",
          "node_count" : 1,
          "pool_id" : "poolfaf38d76"
        },
        "log_export_path" : {
          "obs_url" : "/cn-north-4-training-test/limou/ddp-demo-log/"
        },
        "volumes" : [ {
          "nfs" : {
            "nfs_server_path" : "192.168.0.82:/",
            "local_path" : "/home/ma-user/nfs/",
            "read_only" : false
          }
        } ]
      }
    }
support.huaweicloud.com/api-modelarts/CreateTrainingJob.html