(gcloud.compute.ssh) could not parse resource []

When I return to Google Cloud Platform, after I type

gcloud compute ssh --zone=$ZONE jupyter@$INSTANCE_NAME -- -L 8080:localhost:8080

I got an error from terminal:

(gcloud.compute.ssh) could not parse resource []

Any one knows what was the problem and what should I do?

4 Likes

Hi Yifan,

I ran across the same issue. You may need to permanently store those environment variables in your ~/.bash_profile or ~/.zshrc for my case since I am using zshell.

So first copy these.

export ZONE="us-west2-b" # budget: "us-west1-b"
export INSTANCE_NAME="my-fastai-instance"
export INSTANCE_TYPE="n1-highmem-8" # budget: "n1-highmem-4"

Then inside of your terminal, doesn’t matter where run this command, which should open your editor.
vim ~/.bash_profile

Now paste the environment variables that you copied above at the end of this file and save it.
To make sure the changes take effect immediately run the command source ~/.bash_profile.

Make sure your gcp instance is started by going to your gcp console.

Run your gcloud compute ssh --zone=$ZONE jupyter@$INSTANCE_NAME -- -L 8080:localhost:8080 and now you should be good to go.

16 Likes

Thanks that resolves this issue.

Thank you a lot.
same issue and solved right away:)

I was able to make this work also. Had to learn basic vim commands, but worked!

1 Like

Thanks, very useful!

me too

Hi - I’m having the same problem, trying this solution but I can’t figure out how to save?

Hey Yorke, if you are using vim, then after you make your changes in the editor escape out of edit mode with esc command and enter :x to save.

1 Like

thank you @Mickens - I figured it out.

Hi, Thanks for this tips.

When I typed the above command, the terminal tells me that “Found a swap file by the name ~/.bash_profile.swp”, and “(1) Another program may be editing the same file” or maybe “(2) An edit session for this file crashed”. I tried restarting the computer but still gave me the same thing.

How to resolve this one? Many thanks!

Thanks for this help. It works but sometimes when I come back to my computer the next day I get the same error. If I then run source ~/.bash_profile it works again, even though I haven’t even opened bash_profile this time (see image). Any ideas how to fix this permanently?

thanks, I had the same question and this resolved it.

I have another question - this method shows how to access the notebook tutorials in my browser with instructions from my local terminal. Is there anyway I can access the notebooks in a browser simply by running commands inside the GCP Fastai VM? ie so I don’t have to use my local terminal? Any help much appreciated, thanks

When I enter vim ~/.bash_profile, the terminal opens text which is hard to edit. I can insert some lines after the bottom after pressing ‘s’.

The whole textblock above starts with:
!! Contents within this block are managed by 'conda init' !!

How do I save this bash file?
EDIT: I used

touch ~/.bash_profile; open ~/.bash_profile

This is helpful - thanks David. To anyone else reading this: you need to open a new terminal session to load the new variables.

This is what worked for me:

  1. Run in terminal:

touch ~/.bash_profile; open ~/.bash_profile

  1. It will open in the .bash_profile in text editor.

  2. At the very end of the file, after “Users/…exec -l /bin/bash/google-cloud-sdk/completion.bash.inc’; fi”

Copy and paste:

export ZONE=“us-west2-b”
export INSTANCE_NAME=“name_of_your_fastai_instance”
export INSTANCE_TYPE=“n1-highmem-8”

  1. Save file.
  2. Run in your terminal:

gcloud compute ssh --zone=$ZONE jupyter@$INSTANCE_NAME -- -L 8080:localhost:8080

  1. To launch Jupyter Notebook, type in your browser:
    http://localhost:8080/tree

Hey, this is what worked for me.

I just wen’t through the login part of the setup in the Ubuntu terminal again. Pasting in.

# Create environment variable for correct distribution
export CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)"

# Add the Cloud SDK distribution URI as a package source
echo "deb http://packages.cloud.google.com/apt $CLOUD_SDK_REPO main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list

# Import the Google Cloud Platform public key
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -

# Update the package list and install the Cloud SDK
sudo apt-get update && sudo apt-get install google-cloud-sdk

and running

gcloud init

Then I chose my account and project, then I ran

gcloud compute ssh --zone=$ZONE jupyter@$INSTANCE_NAME – -L 8080:localhost:8080

and it just worked. Hope it was helpful.

Hi, i followed your steps but when i enter this line : source ~/.bash_profile.
it says -bash: /home/vival/.bash_profile.: No such file or directory
can you help me
Edit: And one more question: my instance is on us-west1-b. Should i change it from us-west2-b to us-west1-b? Thanks

Try creating the file first: open a new file use any text editor, name it . bash_profile and save the blank file as it is under your home directory.

And use the zone your instance is on, so your $ZONE will be us-west1-b

Thanks, the problem is solved when i restarted my computer. I am trying to setup fastai v3 for windows now. Thanks again for your instructions.