1
我可以在Google雲機器學習引擎上訓練tensorflow模型。但是,當我使用Keras代碼時,我在Google雲上遇到了錯誤No module named keras
。如何在Google Cloud機器學習引擎上訓練Keras模型
我可以在Google雲機器學習引擎上訓練tensorflow模型。但是,當我使用Keras代碼時,我在Google雲上遇到了錯誤No module named keras
。如何在Google Cloud機器學習引擎上訓練Keras模型
我發現,爲了使用在谷歌雲keras一個人與一個setup.py腳本安裝它,把它放在您運行gcloud指令相同的位置的文件夾:
├── setup.py
└── trainer
├── __init__.py
├── cloudml-gpu.yaml
├── example5-keras.py
而且在setup.py你把內容如:
from setuptools import setup, find_packages
setup(name='example5',
version='0.1',
packages=find_packages(),
description='example to run keras on gcloud ml-engine',
author='Fuyang Liu',
author_email='[email protected]',
license='MIT',
install_requires=[
'keras',
'h5py'
],
zip_safe=False)
然後你就可以開始你的工作在gcloud運行,如:
export BUCKET_NAME=tf-learn-simple-sentiment
export JOB_NAME="example_5_train_$(date +%Y%m%d_%H%M%S)"
export JOB_DIR=gs://$BUCKET_NAME/$JOB_NAME
export REGION=europe-west1
gcloud ml-engine jobs submit training $JOB_NAME \
--job-dir gs://$BUCKET_NAME/$JOB_NAME \
--runtime-version 1.0 \
--module-name trainer.example5-keras \
--package-path ./trainer \
--region $REGION \
--config=trainer/cloudml-gpu.yaml \
-- \
--train-file gs://tf-learn-simple-sentiment/sentiment_set.pickle
要使用GPU,然後在您的模塊中添加文件,內容如下:
trainingInput:
scaleTier: CUSTOM
# standard_gpu provides 1 GPU. Change to complex_model_m_gpu for 4
GPUs
masterType: standard_gpu
runtimeVersion: "1.0"