【发布时间】:2017-10-23 13:20:04
【问题描述】:
我正在尝试构建一个广泛而深入的张量流模型并在谷歌云上对其进行训练。
我已经能够做到这一点并训练较小的开发版本。
但是,我现在正试图扩大到更多数据和更多培训步骤,而我的在线培训工作一直失败。
它运行了 5 分钟左右,然后我收到以下错误:
The replica worker 2 exited with a non-zero status of 1. Termination reason: Error.
To find out more about why your job exited please check the logs: https://console.cloud.google.com/logs/viewer?project=642488228368&resource=ml_job%2Fjob_id%2Fclickmodel_train_20171023_123542&advancedFilter=resource.type%3D%22ml_job%22%0Aresource.labels.job_id%3D%22clickmodel_train_20171023_123542%22
当我查看日志时,我可以看到这些错误似乎是问题所在:
Command '['gsutil', '-q', 'cp', u'gs://pmc-ml/clickmodel/vy/output/packages/4fc20b9f4b7678fd97c8061807d18841050bd95dbbff16a6b78961303203e032/trainer-0.0.0.tar.gz', u'trainer-0.0.0.tar.gz']' returned non-zero exit status 1
我不太确定这里发生了什么。我有一种感觉,这可能与我正在训练模型的机器类型有关。但我已经尝试从“STANDARD_1”移动到“PREMIUM_1”,并且我还尝试将自定义机器类型“complex_model_l”和“large_model”用于参数服务器。
我正在使用的数据中有大约 1400 个特征。
我只在一天的数据上对其进行了 1000 步的训练,而且我已经大大减少了批量大小。我可以像这样在本地训练它,但是当我尝试在云中训练它时(即使步骤如此之少)我遇到了这个错误。
我不确定接下来要尝试什么...
看起来 gsutil 命令可能正在将模型的打包版本复制到本地工作人员,这导致了问题。没想到一个宽而深的模型的 1400 个特征足以让我不得不担心我的模型太大。所以我不确定我是否在我认为正在发生的事情中,正如我所期望的那样,使用其他机器类型和自定义配置可以解决这个问题。
附言这是我正在使用的自定义配置的 yaml:
trainingInput:
scaleTier: CUSTOM
masterType: large_model
workerType: large_model
parameterServerType: large_model
workerCount: 15
parameterServerCount: 10
我训练模型的调用是这样的:
gcloud ml-engine jobs submit training $JOB_NAME \
--stream-logs \
--job-dir $OUTPUT_PATH \
--runtime-version 1.2 \
--config $CONFIG \
--module-name trainer.task \
--package-path $PACKAGE_PATH \
--region $REGION \
--scale-tier CUSTOM \
-- \
--train-files $TRAIN_DATA \
--eval-files $EVAL_DATA \
--train-steps 1000 \
--verbosity DEBUG \
--eval-steps 100 \
--num-layers 2 \
--first-layer-size 200 \
--scale-factor 0.99
上面的$OUTPUT_PATH 只是一天的数据——所以我很确定我的问题不在于输入行和步骤方面的数据过多。我的批量大小也是 100。
更新 我运行了一个超参数调优工作,因为实际上这就是我之前的工作。以下是工作信息:
clickmodel_train_20171023_154805
Failed (10 min 19 sec)
Creation time
Oct 23, 2017, 4:48:08 PM
Start time
Oct 23, 2017, 4:48:12 PM
End time
Oct 23, 2017, 4:58:27 PM
Logs
View logs
Error message
Hyperparameter Tuning Trial #1 Failed before any other successful trials were completed. The failed trial had parameters: num-layers=11, scale-factor=0.47899098586647881, first-layer-size=498, . The trial's error message was: The replica worker 4 exited with a non-zero status of 1. Termination reason: Error. Traceback (most recent call last): File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main "__main__", fname, loader, pkg_name) File "/usr/lib/python2.7/runpy.py", line 72, in _run_code exec code in run_globals File "/root/.local/lib/python2.7/site-packages/trainer/task.py", line 193, in <module> tf.gfile.DeleteRecursively(args.job_dir) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/lib/io/file_io.py", line 432, in delete_recursively pywrap_tensorflow.DeleteRecursively(compat.as_bytes(dirname), status) File "/usr/lib/python2.7/contextlib.py", line 24, in __exit__ self.gen.next() File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/errors_impl.py", line 466, in raise_exception_on_not_ok_status pywrap_tensorflow.TF_GetCode(status)) PermissionDeniedError: could not fully delete dir To find out more about why your job exited please check the logs: https://console.cloud.google.com/logs/viewer?project=642488228368&resource=ml_job%2Fjob_id%2Fclickmodel_train_20171023_154805&advancedFilter=resource.type%3D%22ml_job%22%0Aresource.labels.job_id%3D%22clickmodel_train_20171023_154805%22
Training input
{
"scaleTier": "CUSTOM",
"masterType": "large_model",
"workerType": "standard_gpu",
"parameterServerType": "large_model",
"workerCount": "10",
"parameterServerCount": "5",
"packageUris": [
"gs://pmc-ml/clickmodel/vy/output/packages/326616fb7bab86d0d534c03f3260a0ff38c86112850b478ba28eca1e9d12d092/trainer-0.0.0.tar.gz"
],
"pythonModule": "trainer.task",
"args": [
"--train-files",
"gs://pmc-ml/clickmodel/vy/data/train_data_20170901*.csv",
"--eval-files",
"gs://pmc-ml/clickmodel/vy/data/dev_data_20170901*.csv",
"--train-steps",
"1000",
"--verbosity",
"DEBUG",
"--eval-steps",
"100",
"--num-layers",
"2",
"--first-layer-size",
"200",
"--scale-factor",
"0.99",
"--train-batch-size",
"100",
"--eval-batch-size",
"100"
],
"hyperparameters": {
"goal": "MAXIMIZE",
"params": [
{
"parameterName": "first-layer-size",
"minValue": 50,
"maxValue": 500,
"type": "INTEGER",
"scaleType": "UNIT_LINEAR_SCALE"
},
{
"parameterName": "num-layers",
"minValue": 1,
"maxValue": 15,
"type": "INTEGER",
"scaleType": "UNIT_LINEAR_SCALE"
},
{
"parameterName": "scale-factor",
"minValue": 0.1,
"maxValue": 1,
"type": "DOUBLE",
"scaleType": "UNIT_REVERSE_LOG_SCALE"
}
],
"maxTrials": 12,
"maxParallelTrials": 2,
"hyperparameterMetricTag": "accuracy"
},
"region": "us-central1",
"runtimeVersion": "1.2",
"jobDir": "gs://pmc-ml/clickmodel/vy/output"
}
但我现在遇到以下错误:
16:58:06.188
The replica worker 4 exited with a non-zero status of 1. Termination reason: Error. Traceback (most recent call last): File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main "__main__", fname, loader, pkg_name) File "/usr/lib/python2.7/runpy.py", line 72, in _run_code exec code in run_globals File "/root/.local/lib/python2.7/site-packages/trainer/task.py", line 193, in <module> tf.gfile.DeleteRecursively(args.job_dir) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/lib/io/file_io.py", line 432, in delete_recursively pywrap_tensorflow.DeleteRecursively(compat.as_bytes(dirname), status) File "/usr/lib/python2.7/contextlib.py", line 24, in __exit__ self.gen.next() File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/errors_impl.py", line 466, in raise_exception_on_not_ok_status pywrap_tensorflow.TF_GetCode(status)) PermissionDeniedError: could not fully delete dir To find out more about why your job exited please check the logs: https://console.cloud.google.com/logs/viewer?project=642488228368&resource=ml_job%2Fjob_id%2Fclickmodel_train_20171023_154805&advancedFilter=resource.type%3D%22ml_job%22%0Aresource.labels.job_id%3D%22clickmodel_train_20171023_154805%22
Expand all | Collapse all {
insertId: "w77g2yg1zqa5fl"
logName: "projects/pmc-analytical-data-mart/logs/ml.googleapis.com%2Fclickmodel_train_20171023_154805"
receiveTimestamp: "2017-10-23T15:58:06.188221966Z"
resource: {…}
severity: "ERROR"
textPayload: "The replica worker 4 exited with a non-zero status of 1. Termination reason: Error.
Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/root/.local/lib/python2.7/site-packages/trainer/task.py", line 193, in <module>
tf.gfile.DeleteRecursively(args.job_dir)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/lib/io/file_io.py", line 432, in delete_recursively
pywrap_tensorflow.DeleteRecursively(compat.as_bytes(dirname), status)
File "/usr/lib/python2.7/contextlib.py", line 24, in __exit__
self.gen.next()
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/errors_impl.py", line 466, in raise_exception_on_not_ok_status
pywrap_tensorflow.TF_GetCode(status))
PermissionDeniedError: could not fully delete dir
To find out more about why your job exited please check the logs: https://console.cloud.google.com/logs/viewer?project=642488228368&resource=ml_job%2Fjob_id%2Fclickmodel_train_20171023_154805&advancedFilter=resource.type%3D%22ml_job%22%0Aresource.labels.job_id%3D%22clickmodel_train_20171023_154805%22"
timestamp: "2017-10-23T15:58:06.188221966Z"
}
看起来确实可能是一种许可。我已将 cloud-logs@google.com、cloud-ml-service@pmc-analytical-data-mart-8c548.iam.gserviceaccount.com、cloud-ml@google.com 作为管理员添加到 pmc-ml 存储桶中。我想知道我还缺少什么。
另一个更新
我现在也在日志中看到这些错误,但不确定它们是否相关:
{
insertId: "1986fw7g2uya0b9"
jsonPayload: {
created: 1508774246.95985
levelname: "ERROR"
lineno: 335
message: "2017-10-23 15:57:26.959642: E tensorflow/stream_executor/cuda/cuda_driver.cc:924] failed to allocate 11.17G (11995578368 bytes) from device: CUDA_ERROR_OUT_OF_MEMORY"
pathname: "/runcloudml.py"
}
labels: {
compute.googleapis.com/resource_id: "7863680028519935658"
compute.googleapis.com/resource_name: "worker-f13b3addb0-7-s6dxq"
compute.googleapis.com/zone: "us-central1-c"
ml.googleapis.com/job_id: "clickmodel_train_20171023_154805"
ml.googleapis.com/job_id/log_area: "root"
ml.googleapis.com/task_name: "worker-replica-7"
ml.googleapis.com/trial_id: "1"
}
logName: "projects/pmc-analytical-data-mart/logs/worker-replica-7"
receiveTimestamp: "2017-10-23T15:57:32.288280956Z"
resource: {
labels: {
job_id: "clickmodel_train_20171023_154805"
project_id: "pmc-analytical-data-mart"
task_name: "worker-replica-7"
}
type: "ml_job"
}
severity: "ERROR"
timestamp: "2017-10-23T15:57:26.959845066Z"
}
和
{
insertId: "11qijbbg2nchav0"
jsonPayload: {
created: 1508774068.64571
levelname: "ERROR"
lineno: 335
message: "2017-10-23 15:54:28.645519: E tensorflow/stream_executor/cuda/cuda_driver.cc:924] failed to allocate 11.17G (11995578368 bytes) from device: CUDA_ERROR_OUT_OF_MEMORY"
pathname: "/runcloudml.py"
}
labels: {
compute.googleapis.com/resource_id: "2962580336091050416"
compute.googleapis.com/resource_name: "worker-a28b8b5d9c-8-ch8kg"
compute.googleapis.com/zone: "us-central1-c"
ml.googleapis.com/job_id: "clickmodel_train_20171023_154805"
ml.googleapis.com/job_id/log_area: "root"
ml.googleapis.com/task_name: "worker-replica-8"
ml.googleapis.com/trial_id: "2"
}
logName: "projects/pmc-analytical-data-mart/logs/worker-replica-8"
receiveTimestamp: "2017-10-23T15:54:59.620612418Z"
resource: {
labels: {
job_id: "clickmodel_train_20171023_154805"
project_id: "pmc-analytical-data-mart"
task_name: "worker-replica-8"
}
type: "ml_job"
}
severity: "ERROR"
timestamp: "2017-10-23T15:54:28.645709991Z"
}
我可能会立即将输入数据文件剥离为仅 10 个左右的特征,这样变量就少了一个。然后我将重新运行相同的超参数作业,看看我下次是否只看到权限错误,如果是,我们可以先专注于此。看起来另外两个是记忆的,所以也许我只需要更大的机器或更小批量 - 估计我自己可以用谷歌搜索我的出路......我想...... :)
部分解决方案
好吧,经过一番折腾,我想我遇到了两个问题。
- 我每次运行作业时都在重复使用相同的输出作业目录 (gs://pmc-ml/clickmodel/vy/output) - 我认为当作业失败和下一个作业时这会导致一些问题无论出于何种原因,都无法完全删除一些遗留文件。不是 100% 确定这是否真的是一个问题,但似乎更好的做法是为每个作业创建一个新的输出文件夹。
- 我将“--scale-tier STANDARD_1”作为参数传递,这似乎是导致问题的原因(我只是编造了这个参数吗? - 如果是这样,这很奇怪,它不会在验证作业时引发错误)。
所以这行得通:
gcloud ml-engine jobs submit training test_023 \
--job-dir gs://pmc-ml/clickmodel/vy/output_test_023 \
--runtime-version 1.2 \
--module-name trainer.task \
--package-path /home/andrew_maguire/localDev/codeBase/pmc-analytical-data-mart/clickmodel/trainer/ \
--region us-central1 \
-- \
--train-files gs://pmc-ml/clickmodel/vy/rand_data/train_data_20170901_*.csv \
--eval-files gs://pmc-ml/clickmodel/vy/rand_data/dev_data_20170901_*.csv \
--train-steps 100 \
--verbosity DEBUG
但这失败了:
gcloud ml-engine jobs submit training test_024 \
--job-dir gs://pmc-ml/clickmodel/vy/output_test_024 \
--runtime-version 1.2 \
--module-name trainer.task \
--package-path /home/andrew_maguire/localDev/codeBase/pmc-analytical-data-mart/clickmodel/trainer/ \
--region us-central1 \
--scale-tier STANDARD_1 \
-- \
--train-files gs://pmc-ml/clickmodel/vy/rand_data/train_data_20170901_*.csv \
--eval-files gs://pmc-ml/clickmodel/vy/rand_data/dev_data_20170901_*.csv \
--train-steps 100 \
--verbosity DEBUG
所以我认为我的问题是,当我尝试使用更广泛的模型和大量数据开始扩展时,我开始通过命令行参数传递一些机器配置类型的东西。我不确定我这样做是否正确。似乎我最好将它们留在 hptuning_config.yaml 文件中并尝试使用这样的调用进行扩展:
gcloud ml-engine jobs submit training test_022 \
--job-dir gs://pmc-ml/clickmodel/vy/output_test_022 \
--runtime-version 1.2 \
--module-name trainer.task \
--package-path /home/andrew_maguire/localDev/codeBase/pmc-analytical-data-mart/clickmodel/trainer/ \
--region us-central1 \
--config /home/andrew_maguire/localDev/codeBase/pmc-analytical-data-mart/clickmodel/hptuning_config.yaml \
-- \
--train-files gs://pmc-ml/clickmodel/vy/rand_data/train_data_20170901_*.csv \
--eval-files gs://pmc-ml/clickmodel/vy/rand_data/dev_data_20170901_*.csv \
--train-steps 100 \
--verbosity DEBUG
hptuning_config.yaml 的样子:
trainingInput:
scaleTier: CUSTOM
masterType: large_model
workerType: standard_gpu
parameterServerType: large_model
workerCount: 10
parameterServerCount: 5
hyperparameters:
goal: MAXIMIZE
hyperparameterMetricTag: accuracy
maxTrials: 5
maxParallelTrials: 2
params:
- parameterName: first-layer-size
type: INTEGER
minValue: 20
maxValue: 500
scaleType: UNIT_LINEAR_SCALE
- parameterName: num-layers
type: INTEGER
minValue: 1
maxValue: 15
scaleType: UNIT_LINEAR_SCALE
- parameterName: scale-factor
type: DOUBLE
minValue: 0.01
maxValue: 1.0
scaleType: UNIT_REVERSE_LOG_SCALE
所以我现在将尝试重新添加我的所有功能,并在 1 天进行训练,然后尝试扩大到更多天数和训练步骤等。
关于传递的“--scale-tier STANDARD_1”,我不确定根本原因是什么,或者是否可能存在错误。最初我在想而不是担心计算不同的机器类型等我会在提交作业时通过“--scale-tier PREMIUM_1”,因此(希望)不必担心实际的机器类型等。所以我认为可能也许这里仍然是某种问题。
【问题讨论】:
-
我猜这是权限问题。 gs://pmc-ml 是否属于您正在从事的同一项目 (
gcloud config get-value core/project)?您可能需要通过:cloud.google.com/ml-engine/docs/… 以防万一。能否也提供gsutil -l -h gs://pmc-ml/clickmodel/vy/output/packages/4fc20b9f4b7678fd97c8061807d18841050bd95dbbff16a6b78961303203e032/trainer-0.0.0.tar.gz的输出 -
是的-刚刚在那里再次检查-它们都在同一个项目中。我正在为 gsutil -l -h 命令获取
option -l not recognized...? -
当我的模型中的特征较少时,云运行也可以正常工作。直到添加了我的最后一批功能才开始。我正在尝试可能将我添加的所有最近一批功能设置为未使用的列和/或使用较少的功能重新导出我的数据,看看我是否可以让它再次工作,只是为了确认我的一个想法,它可能是相关的以某种方式增加特征的数量和参数。
-
hmmm - 我刚刚开始了一份功能较少的工作,并且遇到了同样的错误,所以也许我对功能的想法有误。
-
尝试复制 .tar.gz 文件时失败。我是想问你
gsutil ls(忘了ls)。我刚刚跑了subprocess.check_call(['gsutil', '-q', 'cp', u'gs://pmc-ml/clickmodel/vy/output/packages/4fc20b9f4b7678fd97c8061807d18841050bd95dbbff16a6b78961303203e032/trainer-0.0.0.tar.gz', u'trainer-0.0.0.tar.gz'])——显然我无权访问这个文件,我得到了和你一样的错误,但是堆栈跟踪有更多行,即“AccessDeniedException:403 rhaertel@google.com 没有拥有对 pmc-ml 的 storage.objects.list 访问权限。”你有更多关于错误的背景信息吗?
标签: tensorflow google-cloud-ml google-cloud-ml-engine