簡體   English   中英

使用 SageMaker 處理的等效 Glue Spark 配置是什么?

[英]What is the equivalent Glue Spark configuration to use SageMaker processing?

我正在嘗試將 Glue 自定義 PySpark 作業遷移到 SageMaker 處理,以從 SageMaker Pipeline 提供的 MLOps 中受益。

  1. 在 Glue 中,我的工作使用 10 個 G.1X(4 個 CPU,16G 內存)實例並在 10 分鍾內完成。
  2. 我嘗試使用類似的 SageMaker 處理實例(10 ml.m5.xlarge instances with 4 CPUs, 16G memory for each),但失敗了,因為 OOM “OutOfMemoryError: Please use an instance type with more memory, or ensure that your processing container does not使用比可用更多的 memory。” 當我檢查 cloudwatch 實例指標時,所有 10 個實例的最大 memory 使用率僅為 37.4%,因此實際上並沒有用完所有 memory。

Glue 不會在其儀表板上公開spark-submit參數(例如,--conf spark.executor.memory),因此我如何檢查我的 SageMaker 處理作業是否使用與 Glue 作業相同的配置,以及最佳實踐是什么保持他們的火花配置相同?

有一個特定的組件允許您在 Amazon SageMaker 中使用 Apache Spark 進行數據處理

它稱為PySparkProcessor

它像任何其他處理作業一樣工作。 當然,您也可以指定運行參數


指定 memory 配置的示例:

from sagemaker.spark.processing import PySparkProcessor

spark_processor = PySparkProcessor(
    base_job_name="spark-preprocessor",
    framework_version="2.4",
    role=role,
    instance_count=2,
    instance_type="ml.m5.xlarge",
    max_runtime_in_seconds=1200,
)

configuration=[
    {
        "Classification": "spark-defaults",
        "Properties": {
            "spark.driver.memory": "4g"
       },
   }
]

spark_processor.run(
    submit_app="preprocess.py",
    arguments=['s3_input_bucket', bucket,
               's3_input_key_prefix', input_prefix,
               's3_output_bucket', bucket,
               's3_output_key_prefix', output_prefix],
    configuration = configuration
)

您可以使用這段代碼顯示 PySpark Glue 配置:

configurations = spark.sparkContext.getConf().getAll()
for item in configurations: print(item)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM