Dask:任务停滞?

发布于 2025-01-10 14:24:06 字数 1306 浏览 4 评论 0原文

我有一个 dask 批量推理工作负载,它对 50 万行特征应用机器学习预测。我在 AWS 上的 EMR 实例上使用 dask-yarn。似乎有一些掉队的人阻碍了达斯克,我不知道该如何对付他们。对于分配任务,它一直卡在99531/100000,我一直在等待。当我使用 Dask 时,有时它会“卡在”更大的数据集上。

代码示例:

def model_predict(row, model_config, bert_model, bert_tokenizer, xgb_model):

    input_doc = row.to_dict()
    try:
        return predict_one(model_config, bert_model, bert_tokenizer, xgb_model, input_doc)
    except:
        return {'error_code': 500}


all_features_df = dd.read_csv(file)
all_features_df = all_features_df.repartition(npartitions=100000).persist()
all_features_df['prediction_response'] = all_features_df.apply(
        model_predict,
        model_config=base_config,
        bert_model=bert,
        bert_tokenizer=tokenizer,
        xgb_model=xgb,
        axis=1, 
        meta=('prediction_response', 'object'))
all_features_df = all_features_df.persist()
all_features_df.repartition(partition_size="100MB").to_parquet(f's3://my_data/predictions/batch={batch}/',
                                                       engine='pyarrow',
                                                       schema='infer')

“在此处输入图像描述"

I have a dask batch inferencing work load that's applying machine learning predictions against 500K rows of features. I'm using dask-yarn on an EMR instance on AWS. There seems to be some stragglers that are holding up Dask and I am not sure how to deal with them. For the assign task, it's been stuck at 99531/100000, and I've been waiting forever. There have been other times when I've used Dask and it sometimes gets "stuck" on bigger datasets.

Code Example:

def model_predict(row, model_config, bert_model, bert_tokenizer, xgb_model):

    input_doc = row.to_dict()
    try:
        return predict_one(model_config, bert_model, bert_tokenizer, xgb_model, input_doc)
    except:
        return {'error_code': 500}


all_features_df = dd.read_csv(file)
all_features_df = all_features_df.repartition(npartitions=100000).persist()
all_features_df['prediction_response'] = all_features_df.apply(
        model_predict,
        model_config=base_config,
        bert_model=bert,
        bert_tokenizer=tokenizer,
        xgb_model=xgb,
        axis=1, 
        meta=('prediction_response', 'object'))
all_features_df = all_features_df.persist()
all_features_df.repartition(partition_size="100MB").to_parquet(f's3://my_data/predictions/batch={batch}/',
                                                       engine='pyarrow',
                                                       schema='infer')

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文