Running a python script on Google Cloud Compute Engine

后端 未结 4 1763
死守一世寂寞
死守一世寂寞 2020-12-13 15:33

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

相关标签:
4条回答
  • 2020-12-13 16:06

    I used Way Script which is great and have a free plan to run every hour

    You can check this video to see explanation

    0 讨论(0)
  • 2020-12-13 16:07

    Just navigate to the directory where the script is placed.

    python thenameofscript.py
    
    0 讨论(0)
  • 2020-12-13 16:15

    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 sure to add the following in your Python File as the first line to make it executable

    ' #!/usr/bin/python3 '

    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
    
    0 讨论(0)
  • 2020-12-13 16:19

    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 default in standard environment

    0 讨论(0)
提交回复
热议问题