やろうとしたこと
https://cloud.google.com/ml-engine/docs/training-jobs?hl=ja
にある内容を自分で試して見ようと思い下のようなPythonスクリプトを書きました。
python
1from googleapiclient import discovery 2import os 3os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = '(credentialへのパス)' 4 5training_input = { 6 'scaleTier': 'CUSTOM', 7 'masterType': 'complex_model_m', 8 'workerType': 'complex_model_m', 9 'parameterServerType': 'large_model', 10 'workerCount': 2, 11 'parameterServerCount': 1, 12 'packageUris': ['gs://unet-test2/'], 13 'pythonModule': 'UNet.train', 14 'args': [ 15 '--train_data', 'gs://unet-test2/UNet/dataset/raw_images', 16 '--segmented_data', 'gs://unet-test2/UNet/dataset/segmented_images' 17 '--epochs', '10', 18 '--batch_size', '10', 19 ], 20 'region': 'asia-east1', 21 'jobDir': 'gs://unet-test2', 22 'runtimeVersion': '1.14', 23 'pythonVersion': '3.5' 24} 25job_spec = {'jobId': "(username)_unet", 'trainingInput': training_input} 26project_name = "(プロジェクト名)" 27project_id = "projects/(プロジェクトID)" 28 29cloudml = discovery.build('ml', 'v1') 30request = cloudml.projects().jobs().create(body=job_spec, parent=project_id) 31response = request.execute()
これを実行したところ、下のようなエラーが出てしまいます。
bash
1Traceback (most recent call last): 2 File "ai-platform.py", line 32, in <module> 3 response = request.execute() 4 File "C:\Users(username)\Miniconda3\lib\site-packages\googleapiclient\_helpers.py", line 130, in positional_wrapper 5 return wrapped(*args, **kwargs) 6 File "C:\Users(username)\Miniconda3\lib\site-packages\googleapiclient\http.py", line 856, in execute 7 raise HttpError(resp, content, uri=self.uri) 8googleapiclient.errors.HttpError: <HttpError 400 when requesting https://ml.googleapis.com/v1/projects/(プロジェクトID)/jobs?alt=json returned "Field: package_uris Error: The provided GCS paths [gs://unet-test2/] cannot be read. Please make sure that the objects exist and you have read access to it.". Details: "[{'@type': 'type.googleapis.com/google.rpc.BadRequest', 'fieldViolations': [{'field': 'package_uris', 'description': 'The provided GCS paths [gs://unet-test2/] cannot be read. Please make sure that the objects exist and you have read access to it.'}]}]">
確認したこと
- 計算環境とGCSのリージョンが違うから見つけられないのではないかと思い、バケットのリージョンを"asia-east1"に合わせて実行しなおしたが同じエラー
- バケット名が違うのではないかと思い、
gsutil
コマンドを実行してみた。結果は
bash
1$ gsutil ls 2 3gs://unet-test2/
となり、あっているはず。
どのようにしたら GCS にアクセスができるようになるでしょうか?よろしくおねがいします。
あなたの回答
tips
プレビュー