DEV Community

David Haley
David Haley

Posted on

Getting notebook's machine type on Vertex AI

I'd like a Vertex AI notebook to output the machine type it's running. I found this StackOverflow reference to use the Compute Engine metadata server.

But this doesn't work with Vertex AI. (Not all roads lead to Compute Engine.)

Here's how I did it, using the notebook ID given in the workbench:

gcloud notebooks runtimes describe --format="value(virtualMachine.virtualMachineConfig.machineType)" --location=<region> <notebook_id>
n1-standard-2
Enter fullscreen mode Exit fullscreen mode

The value format prints out just the return value: no header or other information to parse out. I learned a lot about potential formats, see also: gcloud topic formats

So in a notebook running Python, just do:

! gcloud etc
Enter fullscreen mode Exit fullscreen mode

Top comments (0)