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

时间:2024-05-31 10:18:55

请求示例

  • 如下以创建名为“TestModelArtsJob”,描述为“This is a ModelArts job”为例。
    POST    https://endpoint/v1/{project_id}/training-jobs
    {
        "job_name": "TestModelArtsJob",
        "job_desc": "This is a ModelArts job",
        "workspace_id": "af261af2218841ec960b01ab3cf1a5fa",
        "config": {
            "worker_server_num": 1,
            "app_url": "/usr/app/",
            "boot_file_url": "/usr/app/boot.py",
            "parameter": [
                {
                    "label": "learning_rate",
                    "value": "0.01"
                },
                {
                    "label": "batch_size",
                    "value": "32"
                }
            ],
            "dataset_id": "38277e62-9e59-48f4-8d89-c8cf41622c24",
            "dataset_version_id": "2ff0d6ba-c480-45ae-be41-09a8369bfc90",
            "spec_id": 1,
            "engine_id": 1,
            "train_url": "/usr/train/",
            "log_url": "/usr/log/",
            "model_id": 1,
            "pool_id": "testpool"
        }
    }
  • 如下以创建名为“TestModelArtsJob2”,创建 自定义镜像 训练。
    POST    https://endpoint/v1/{project_id}/training-jobs
    {
        "job_name": "TestModelArtsJob2",
        "job_desc": "This is a ModelArts job",
        "workspace_id": "af261af2218841ec960b01ab3cf1a5fa",
        "config": {
            "worker_server_num": 1,
            "data_url": "/usr/data/",
            "app_url": "/usr/app/",
            "boot_file_url": "/usr/app/boot.py",
            "parameter": [
                {
                    "label": "CUSTOM_PA RAM 1",
                    "value": "1"
                }
            ],
            "spec_id": 1,
            "user_command": "bash -x /home/work/run_train.sh python /home/work/user-job-dir/app/mnist/mnist_softmax.py --data_url /home/work/user-job-dir/app/mnist_data",
            "user_image_url": "100.125.5.235:20202/jobmng/custom-cpu-base:1.0",
            "train_url": "/usr/train/",
            "log_url": "/usr/log/",
            "model_id": 1,
            "pool_id": "testpool",
            "engine_id": 1 
        }
    }
  • 如下以创建名为“TestModelArtsJob3”,创建使用存储卷的训练。
    POST    https://endpoint/v1/{project_id}/training-jobs
    {
        "job_name": "TestModelArtsJob3",
        "job_desc": "This is a ModelArts job",
        "workspace_id": "af261af2218841ec960b01ab3cf1a5fa",
        "config": {
            "worker_server_num": 1,
            "app_url": "/usr/app/",
            "boot_file_url": "/usr/app/boot.py",
            "parameter": [
                {
                    "label": "learning_rate",
                    "value": "0.01"
                },
                {
                    "label": "batch_size",
                    "value": "32"
                }
            ],
            "dataset_id": "38277e62-9e59-48f4-8d89-c8cf41622c24",
            "dataset_version_id": "2ff0d6ba-c480-45ae-be41-09a8369bfc90",
            "spec_id": 1,
            "engine_id": 1,
            "train_url": "/usr/train/",
            "log_url": "/usr/log/",
            "model_id": 1,
            "pool_id": "testpool",
            "volumes": [
                {
                    "nfs": {
                        "id": "43b37236-9afa-4855-8174-32254b9562e7",
                        "src_path": "192.168.8.150:/",
                        "dest_path": "/home/work/nas",
                        "read_only": false
                    }
                },
                {
                    "host_path": {
                        "src_path": "/root/work",
                        "dest_path": "/home/mind",
                        "read_only": false
                    }
                }
            ]
        }
    }
support.huaweicloud.com/api-modelarts/modelarts_03_0045.html