Search code examples
google-cloud-platformjupyter-notebookgcloud

How Can I add a start-up script to an existing ai notebook instance on google cloud?


I know how to do it when I create an instance:

gcloud compute instances create ${INSTANCE_NAME} \
  --machine-type=n1-standard-8 \
  --scopes=https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/userinfo.email \
  --min-cpu-platform="Intel Skylake" \
  ${IMAGE} \
  --image-project=deeplearning-platform-release \
  --boot-disk-size=100GB \
  --boot-disk-type=pd-ssd \ 
  --accelerator=type=nvidia-tesla-p100,count=1 \
  --boot-disk-device-name=${INSTANCE_NAME} \
  --maintenance-policy=TERMINATE --restart-on-failure \
  --metadata="proxy-user-mail=${GCP_LOGIN_NAME},install-nvidia-driver=True,startup-script=${STARTUP_SCRIPT}"

but what if I already have an instance, how do I update/create the startup script?


Solution

  • To add or update the metadata, you can use the endpoint "add-metadata" like this

    gcloud compute instances add-metadata ${INSTANCE_NAME} \
      --metadata startup-script=${NEW_STARTUP_SCRIPT}
    

    The other metadatas are kept.