Dask:任务停滞?
我有一个 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')
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论