I found that to use keras in the Google Cloud, you need to install it using setup.py script and put it in a folder in the same place where you run the gcloud command:
├── setup.py └── trainer ├── __init__.py ├── cloudml-gpu.yaml ├── example5-keras.py
And in setup.py you place the content, for example:
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=' fuyang.liu@example.com ', license='MIT', install_requires=[ 'keras', 'h5py' ], zip_safe=False)
Then you can run your work on gcloud, for example:
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
To use the GPU, add a cloudml-gpu.yaml with the following contents to your file:
trainingInput: scaleTier: CUSTOM # standard_gpu provides 1 GPU. Change to complex_model_m_gpu for 4 GPUs masterType: standard_gpu runtimeVersion: "1.0"
Fuyang liu
source share