User Tools

Site Tools


googlecloud

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

googlecloud [2017/10/26 19:15]
humphrey
googlecloud [2021/06/30 23:42]
Line 1: Line 1:
-====== Deep Learning on the Google Cloud Platform ====== 
  
- 
-==== Installing gcloud on a local machine ==== 
- 
-1. Install gcloud sdk on your local machine (I personally used window linux subsystem, therefore I chose the apt-get option) 
-reference: https://​cloud.google.com/​sdk/​downloads 
- 
-2. Use the following code to setup user account, including setting region of computation unit. 
- 
-<​code>​ gcloud init </​code>​ 
- 
----- 
-==== Setup google cloud storage device ==== 
- 
-3. On the web api (link: https://​console.cloud.google.com),​ click on the drop down manual on the top left hand corner -> click on storage -> click on browse, and create a new storage bucket if there hasn't been one. Let's call it byu_tf_ml in this example. 
- 
----- 
-==== Submit a learning job to google cloud ==== 
- 
-4. On the local machine console, call the following command: 
-<​code> ​ 
-gcloud ml-engine jobs submit training ​ 
- [job_id] 
- --package-path [scource_dir] ​ 
- --module-name [scource_dir.main_script] ​ 
- --staging-bucket gs://​[save_to_directory] 
- --scale-tier BASIC_GPU 
-</​code>​ 
- 
-reference: https://​cloud.google.com/​sdk/​gcloud/​reference/​ml-engine/​jobs/​submit/​training 
- 
-The command "​gcloud ml-engine jobs submit training"​ is a google cloud version to package up our python machine learning job, uploading that to the cloud platform and then run it on some cloud machines. There four fields are required: 
- 
- a. job: In our example, the value is [job_id] in the example, it's the job id showing up in the web api after submitting the job. 
-  ​ 
- b. package-path:​ The local machine directory which contains the python source code. 
-  ​ 
- c. module-name:​ The main python script. 
-  ​ 
- d. staging-bucket:​ The place on google cloud in which the machine learning source code is stored. 
- 
-and these are optional: 
- 
- e. scale-tier: There are BASIC, BASIC_GPU, PREMIUM_1, STANDARD_1, CUSTOM, five different tiers, standing for different level of resources to be used. 
-  
- f. packages: The path where packages you imported into the project but not listed here: https://​cloud.google.com/​ml-engine/​docs/​concepts/​runtime-version-list 
- 
----- 
-===Hints:​=== 
-  
-1. In order to save and retrieve data on google cloud machines, specify the path of input and output as <​code>​gs://​[bucket_name]/​[io_directory]</​code>​ 
- 
-2. Python cannot realize "​gs:"​ prefix, we need to use "​tf.gfile.Open"​ to import file, for example: 
-<code python> 
-def unpickle( file ): 
- import cPickle 
- with tf.gfile.Open(file,​ '​rb'​) as fo: 
- dic = cPickle.load(fo) 
- return dic 
-</​code>​ 
- 
-3. You need a <​code>​__init__.py</​code>​ file in your source code directory in order to make it work. You can keep it as an empty file. 
- 
----- 
-==== Check the results ==== 
- 
-1. On the web api, click on the drop down manual on the top left hand corner -> click on ML Engine -> click on job. You should be able to see the project submitted. 
- 
-2. After the training finished, you will be able to see the results and logs under corresponding job. And if there are any outputs from your job, they should have been stored in the corresponding folder under the gs path. 
- 
-3. Run the following command in Cloud Shell to start TensorBoard. 
-<​code>​ tensorboard --port 8080 --logdir gs://​[bucket_name]/​[output_directory] </​code>​ 
- 
-4. To open a new browser window, select Preview on port 8080 from the Web preview menu in the top-right corner of the Cloud Shell toolbar. 
- 
----- 
-==== Related resources ==== 
-1. If you want to reuse the trained weights of of the model, include the savedmodel function in the application. 
-Reference: https://​cloud.google.com/​ml-engine/​docs/​concepts/​prediction-overview 
- 
-2. You may want to check out more examples online. Reference: https://​cloud.google.com/​sdk/​gcloud/​reference/​ml-engine/​jobs/​submit/​training 
googlecloud.txt ยท Last modified: 2021/06/30 23:42 (external edit)