python - 如何将参数传递给 Azure 机器学习服务中的训练脚本?
问题描述
我正在尝试使用工作区中的对象在Azure VM 上本地提交 Azure 机器学习服务中的实验,如ScriptRunConfig
ws
from azureml.core import ScriptRunConfig
from azureml.core.runconfig import RunConfiguration
from azureml.core import Experiment
experiment = Experiment(ws, name='test')
run_local = RunConfiguration()
script_params = {
'--data-folder': './data',
'--training-data': 'train.csv'
}
src = ScriptRunConfig(source_directory = './source_dir',
script = 'train.py',
run_config = run_local,
arguments = script_params)
run = experiment.submit(src)
但是,这失败了
ExperimentExecutionException: { "error_details": { "correlation": { "operation": "bb12f5b8bd78084b9b34f088a1d77224", "request": "iGfp+sjC34Q=" }, "error": { "code": "UserError", "message": “无法反序列化运行定义”
更糟糕的是,如果我将数据文件夹设置为使用数据存储(我可能需要这样做)
script_params = {
'--data-folder': ds.path('mydatastoredir').as_mount(),
'--training-data': 'train.csv'
}
错误是
UserErrorException:runconfigs 中不支持具有非本机 python 类型值的字典。
{'--data-folder': $AZUREML_DATAREFERENCE_d93269a580ec4ecf97be428cd2fe79, '--training-data': 'train.csv'}
我不太明白我应该如何将我的script_params
参数传递给我的train.py
(不幸的是,文档中ScriptRunConfig
没有包含很多细节)。
有人知道如何src
在这两种情况下正确创建吗?
解决方案
最后我放弃ScriptRunConfig
并使用Estimator
如下方式通过script_params
(在提供了计算目标之后):
estimator = Estimator(source_directory='./mysourcedir',
script_params=script_params,
compute_target='cluster',
entry_script='train.py',
conda_packages = ["pandas"],
pip_packages = ["git+https://github.com/..."],
use_docker=True,
custom_docker_image='<mydockeraccount>/<mydockerimage>')
这也允许我通过在https://hub.docker.com/上放置一个从 Dockerfile 创建的 Docker 映像来安装我的pip_packages
依赖项,例如:custom_docker_image
FROM continuumio/miniconda
RUN apt-get update
RUN apt-get install git gcc g++ -y
(有效!)
推荐阅读
- cuda - 如何使用 NSight Compute 2019 CLI 获取内核的执行时间?
- c++ - 我的中位数计算器中的输出问题
- nightwatch.js - 日志驱动程序日志文件的配置
- javascript - 结帐页面注销用户
- flutter - 在 Flutter 和 Firestore 中使用新数据更新 StreamBuilder
- ibm-cloud - 如何使用最新的 IBM Waston Studio API 解决 .MPS 文件
- json - 如何使用 JSON 字符串中的给定参数启动 Firefox?
- html - python3 manage.py findstatic 找不到静态文件
- javascript - 如何将事件侦听器添加到具有相同类的多个输入
- java - 新建maven项目时pom.xml出现错误如何解决