william zhao
william zhao

Reputation: 35

Could google cloud platform vertextAI running code on backend without output?

The problem is my local internet connection is unstable, I could run the code through Jupyter to the interactive google cloud platform vertexAI, while it seems that there're always outputs returns back to the Jupyter interface. So when my local internet connection is interrupted, the code running is also interrupted.

Is there any methods that I could let the codes just run on the vertexAI backends? Then outputs could be written in the log file at last.

This could be a very basic question. Thanks.

enter image description here

Upvotes: 1

Views: 2201

Answers (1)

Ricco D
Ricco D

Reputation: 7287

To be able to run your notebook on the background, I did the following steps:

  1. Open Jupyter notebook in GCP > Vertex AI > Workbench > Open Jupyterlab
  2. Open a terminal
  3. Use the command below.
    nohup jupyter nbconvert --to notebook --execute test.ipynb &
    
    • nohup and & is added so that the command will run on the background
    • Output logs for the actual command will be appened to file nohup.out
    • Use jupyter nbconvert --to notebook --execute test.ipynb to execute the notebook specified after --execute. --to notebook will create a new notebook that contains the executed notebook with its logs.
    • There other formats other than notebook to convert it. You can read thru more in nbconvert documentation.

For testing I made notebook (test.ipynb) that has a loop that runs for 1.5 hours, that should emulate a long process.

import time

for x in range(1,1080):
    print(x)
    time.sleep(5)

I ran the command provided above and closed my notebook and anything related to GCP. After 1.5 hours I opened the notebook and terminal says its done.

Terminal upon checking back after 1.5 hours: enter image description here

Content of nohup.out:

enter image description here

It created a new notebook named "test.nbconvert.ipynb" that contains the code from test.ipynb and its output.

Snippet of test.nbconvert.ipynb as seen below. It completed the loop up to 1080 iterations that took 1.5 hours:

enter image description here

Upvotes: 2

Related Questions