選取您的 Cookie 偏好設定

我們使用提供自身網站和服務所需的基本 Cookie 和類似工具。我們使用效能 Cookie 收集匿名統計資料,以便了解客戶如何使用我們的網站並進行改進。基本 Cookie 無法停用,但可以按一下「自訂」或「拒絕」以拒絕效能 Cookie。

如果您同意,AWS 與經核准的第三方也會使用 Cookie 提供實用的網站功能、記住您的偏好設定,並顯示相關內容,包括相關廣告。若要接受或拒絕所有非必要 Cookie,請按一下「接受」或「拒絕」。若要進行更詳細的選擇,請按一下「自訂」。

編譯模型 (AWS Command Line Interface)

焦點模式
編譯模型 (AWS Command Line Interface) - Amazon SageMaker AI

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

本節說明如何使用 AWS Command Line Interface (CLI) 管理機器學習模型的 Amazon SageMaker Neo 編譯任務。您可以建立、描述、停止和列出編譯任務。

  1. 建立編譯任務

    使用 CreateCompilationJob API 作業,您可以指定資料輸入格式、儲存模型用的 S3 儲存貯體、寫入編譯模型用的 S3 儲存貯體,以及目標硬體裝置或平台。

    下表說明如何根據目標是裝置或平台設定 CreateCompilationJob API。

    Device Example
    { "CompilationJobName": "neo-compilation-job-demo", "RoleArn": "arn:aws:iam::<your-account>:role/service-role/AmazonSageMaker-ExecutionRole-yyyymmddThhmmss", "InputConfig": { "S3Uri": "s3://<your-bucket>/sagemaker/neo-compilation-job-demo-data/train", "DataInputConfig": "{'data': [1,3,1024,1024]}", "Framework": "MXNET" }, "OutputConfig": { "S3OutputLocation": "s3://<your-bucket>/sagemaker/neo-compilation-job-demo-data/compile", # A target device specification example for a ml_c5 instance family "TargetDevice": "ml_c5" }, "StoppingCondition": { "MaxRuntimeInSeconds": 300 } }

    如果您使用 PyTorch 架構訓練模型,且目標裝置是 ml_* 目標,則可以選擇性指定與 FrameworkVersion 欄位搭配使用的架構版本。

    { "CompilationJobName": "neo-compilation-job-demo", "RoleArn": "arn:aws:iam::<your-account>:role/service-role/AmazonSageMaker-ExecutionRole-yyyymmddThhmmss", "InputConfig": { "S3Uri": "s3://<your-bucket>/sagemaker/neo-compilation-job-demo-data/train", "DataInputConfig": "{'data': [1,3,1024,1024]}", "Framework": "PYTORCH", "FrameworkVersion": "1.6" }, "OutputConfig": { "S3OutputLocation": "s3://<your-bucket>/sagemaker/neo-compilation-job-demo-data/compile", # A target device specification example for a ml_c5 instance family "TargetDevice": "ml_c5", # When compiling for ml_* instances using PyTorch framework, use the "CompilerOptions" field in # OutputConfig to provide the correct data type ("dtype") of the model’s input. Default assumed is "float32" "CompilerOptions": "{'dtype': 'long'}" }, "StoppingCondition": { "MaxRuntimeInSeconds": 300 } }
    備註:
    • 如果您使用 PyTorch 2.0 或更新版本儲存模型,則 DataInputConfig 欄位為選用欄位。SageMaker AI Neo 會從您使用 PyTorch 建立的模型定義檔案取得輸入組態。如需如何建立定義檔案的詳細資訊,請參閱 SageMaker AI Neo 儲存模型PyTorch一節。

    • 僅針對 PyTorch 支援此 API 欄位。

    Platform Example
    { "CompilationJobName": "neo-test-compilation-job", "RoleArn": "arn:aws:iam::<your-account>:role/service-role/AmazonSageMaker-ExecutionRole-yyyymmddThhmmss", "InputConfig": { "S3Uri": "s3://<your-bucket>/sagemaker/neo-compilation-job-demo-data/train", "DataInputConfig": "{'data': [1,3,1024,1024]}", "Framework": "MXNET" }, "OutputConfig": { "S3OutputLocation": "s3://<your-bucket>/sagemaker/neo-compilation-job-demo-data/compile", # A target platform configuration example for a p3.2xlarge instance "TargetPlatform": { "Os": "LINUX", "Arch": "X86_64", "Accelerator": "NVIDIA" }, "CompilerOptions": "{'cuda-ver': '10.0', 'trt-ver': '6.0.1', 'gpu-code': 'sm_70'}" }, "StoppingCondition": { "MaxRuntimeInSeconds": 300 } }
    { "CompilationJobName": "neo-compilation-job-demo", "RoleArn": "arn:aws:iam::<your-account>:role/service-role/AmazonSageMaker-ExecutionRole-yyyymmddThhmmss", "InputConfig": { "S3Uri": "s3://<your-bucket>/sagemaker/neo-compilation-job-demo-data/train", "DataInputConfig": "{'data': [1,3,1024,1024]}", "Framework": "MXNET" }, "OutputConfig": { "S3OutputLocation": "s3://<your-bucket>/sagemaker/neo-compilation-job-demo-data/compile", # A target device specification example for a ml_c5 instance family "TargetDevice": "ml_c5" }, "StoppingCondition": { "MaxRuntimeInSeconds": 300 } }

    如果您使用 PyTorch 架構訓練模型,且目標裝置是 ml_* 目標,則可以選擇性指定與 FrameworkVersion 欄位搭配使用的架構版本。

    { "CompilationJobName": "neo-compilation-job-demo", "RoleArn": "arn:aws:iam::<your-account>:role/service-role/AmazonSageMaker-ExecutionRole-yyyymmddThhmmss", "InputConfig": { "S3Uri": "s3://<your-bucket>/sagemaker/neo-compilation-job-demo-data/train", "DataInputConfig": "{'data': [1,3,1024,1024]}", "Framework": "PYTORCH", "FrameworkVersion": "1.6" }, "OutputConfig": { "S3OutputLocation": "s3://<your-bucket>/sagemaker/neo-compilation-job-demo-data/compile", # A target device specification example for a ml_c5 instance family "TargetDevice": "ml_c5", # When compiling for ml_* instances using PyTorch framework, use the "CompilerOptions" field in # OutputConfig to provide the correct data type ("dtype") of the model’s input. Default assumed is "float32" "CompilerOptions": "{'dtype': 'long'}" }, "StoppingCondition": { "MaxRuntimeInSeconds": 300 } }
    備註:
    • 如果您使用 PyTorch 2.0 或更新版本儲存模型,則 DataInputConfig 欄位為選用欄位。SageMaker AI Neo 會從您使用 PyTorch 建立的模型定義檔案取得輸入組態。如需如何建立定義檔案的詳細資訊,請參閱 SageMaker AI Neo 儲存模型PyTorch一節。

    • 僅針對 PyTorch 支援此 API 欄位。

    注意

    若為 OutputConfig API 作業,TargetDeviceTargetPlatform API 作業互斥。您必須選擇兩個選項之一。

    若要取決於架構尋找 DataInputConfig 的 JSON 字串範例,請參閱 Neo 期望的輸入資料形狀

    如需設定組態的更多相關資訊,請參閱 SageMaker API 參考資料中的 InputConfigOutputConfigTargetPlatform API 作業。

  2. 設定 JSON 檔案之後,執行下列命令建立編譯任務:

    aws sagemaker create-compilation-job \ --cli-input-json file://job.json \ --region us-west-2 # You should get CompilationJobArn
  3. 執行下列命令,描述編譯任務:

    aws sagemaker describe-compilation-job \ --compilation-job-name $JOB_NM \ --region us-west-2
  4. 執行下列命令,停止編譯任務:

    aws sagemaker stop-compilation-job \ --compilation-job-name $JOB_NM \ --region us-west-2 # There is no output for compilation-job operation
  5. 執行下列命令,列出編譯任務:

    aws sagemaker list-compilation-jobs \ --region us-west-2
隱私權網站條款Cookie 偏好設定
© 2025, Amazon Web Services, Inc.或其附屬公司。保留所有權利。