Running a python script on Google Cloud Compute En

2019-02-18 02:44发布

For a machine learning task at school I wrote my own MLP network. The data set is quite big, and training takes forever. I was alerted to the option of running my script on the Google Cloud Compute Engine. I tried to set this up, but did not succeed (yet).

The steps I undertook where:

  1. Create an account
  2. Create a VM
  3. Open the VM via the browser

Can anyone help me with importing and running my python script into the Google Cloud. Or does anyone have clear a tutorial on how to solve this? I tried finding these myself, but had no success so far.

3条回答
虎瘦雄心在
2楼-- · 2019-02-18 03:00

Just navigate to the directory where the script is placed.

python thenameofscript.py
查看更多
爷、活的狠高调
3楼-- · 2019-02-18 03:00

You can use Google cloud platform tutorials itself and is very simple to follow. Links are given below

Setting up python

https://cloud.google.com/python/setup

Getting started

https://cloud.google.com/python/getting-started/hello-world

Please note that you don't have any free tier to run Python 3.x, Standard environment with free tier only supports Python 2.x.

Edit: As per the latest update Python 3.x is also available for standard environment

查看更多
看我几分像从前
4楼-- · 2019-02-18 03:20

I finally figured this out so I'll post the same answer on my own post that worked for me here. Using Debian Stretch on my VM. I'm assuming you already uploaded your file(s) to the VM and that you are in the same directory of your script.

  1. Make your script an executable

    chmod +x myscript.py
    
  2. Run the nohup command to execute the script in the background. The & option ensures that the process stays alive after exiting. I've added the shebang line to my python script so there's no need to call python here

    nohup /path/to/script/myscript.py &
    
  3. Logout from the shell if you want

    logout
    

Done! Now your script is up and running. You can login back and make sure that your process is still alive by checking the output of this command:

ps -e | grep myscript.py

If anything went wrong, you can check out the nohup.out file to see the output of your script:

cat nohup.out
查看更多
登录 后发表回答