google cloud AI notebook save does not work - jupyter-lab

I created a deep learning instance inside the AI platform of google cloud . I use the built in jupyterlab notebooks running on the browser (I use chrome). Recently I have a problem with saving the code. autosave as well as saving the notebook files does not work. I keep see the message "saving started" when I try to save, but nothing other than that happens, and the code is not saved. I tried restart the kernel as well as restart the instance but the problem keeps returning. Anyone here encountered the same thing? have a solution?
thanks

What worked for me eventually was instead of using https connection I connected to the instance via ssh and then to accessed jupyterlab in local host. I followed this link:
https://cloud.google.com/ai-platform/deep-learning-vm/docs/jupyter
export PROJECT_ID="my-project-id"
export ZONE="my-zone"
export INSTANCE_NAME="my-instance"
gcloud compute ssh --project $PROJECT_ID --zone $ZONE \
$INSTANCE_NAME -- -L 8080:localhost:8080

I had a similar problem, I opened a notebook and GCP did not save it,
but after I started the notebook from a folder inside Jupyterlab - it saved it.

Related

how to visualize images in debug console when im using vscode via remote ssh

I am using vscode remote ssh and connect to my server (a node in a cluster) via ssh.
My local machine is Windows and my Host is ubuntu.
My vscode is being used to code in python.
I am trying for weeks to be able to run a python code and display images in the debug console like what we do in the normal terminal or in jupyter notebook, but I notice that I cannot display the image in the debug console at all.
here is a toy example
import numpy as np
import matplotlib.pyplot as plt
img = np.random.rand(300,200)
plt.imshow(img);plt.show()
basically when I try to do plt.imshow(img);plt.show() in the debug console I either get nothing or I get qt.qpa.screen: QXcbConnection: Could not connect to display localhost:0.0 Could not connect to any X display. .
I tried several methods such as using x11 extenson or adding x11 forwarding in the putty or add Display in the launch.json. However, none of them works.
I am coming to the conclusion that vscode remote ssh and debug console in python dont have that feature yet. But if you know a way to do it PLEASE let me know.
I hope that I am clear that displaying image in the normal situation is working and it is not working in the debug situation.
Please note that when I am doing the debug I dont want to display the image out side of the debug console.
Thanks
it seems you have done the first steps of my proposed solution.
open your settings in vscode with ctrl+, and search for terminal.integrated.env.linux. Click Edid settings.json
Update terminal.integrated.env.linux to this
"terminal.integrated.env.linux": {
"DISPLAY": "localhost:10.0",
}
Shut down vscode
Open ssh conncetion to server with ssh -X user#host
Open vscode and use remote development add-on as usually.
Now, this will work indefinitely, just open the x11-forwarding on the side every time. The downside, for which I am currently searching for solution is that you need to remove the "DISPLAY": "localhost:10.0" every time you wish to develop locally, which is not optimal.
Edit: Since you are apparently using windows, you need to configure putty with X11 forwarding and use xming or other x11-forwarding software in place of my step 4.

Debug scenario for lambda

As usual many things to do and no time to do it, so I need some suggestions.
This the scenario. AWS Lambda development based on SAM cli (aws cli/sam cli/docker/IntelliJ with AWS plugin) on Ubuntu 18.04
Developing a lambda function on node.js 12 - Javascript.
Everything is almost working perfectly. I edit the function, run from IntelliJ, docker is executed with the lambda function, logs are happily popping up.
I say almost because I have a problem.
I create a text file in the function and is saved on /tmp/myTextFile.txt
I would like to be able to see the content of this file.
So I was wondering if exists a way to do it accessing the docker image.
I did try to "debug" the function rather than just execute it, putting a breakpoint after generating and saving the file.
I verified that the docker image remains open when the breakpoint is hit.
Then I did try to attach a terminal to the open docker image, no errors but also nothiing happens.
On a terminal I did open a terminal and :
docker container ls
I did see the docker image opened from the the local SAM development
Then :
docker container attach "ID of the opened image"
and .. nothing.
There is a way to login and execute commands like "ls" or "cat" ?
In this way I could see if the file was generated and if is correct.
Thanks for any suggestion !
Steve

Removing need for passphrase key in Google Cloud Projects

I am trying to set up datalab notebooks in a Google Cloud project. I screwed up and entered a passphrase during the first
$ datalab connect INSTANCE_NAME
install.I quickly realized that I wished I hadn't done that, so I deleted the instance and tried to reinstall. It asked again.
So, I did a bit of googling (after just deleting the new project and creating a new one), and discovered that the passphrase is required across projects.
So, I went to the metadata tab and deleted it through there- but it comes back whenever I try and create an instance (on any project) through the terminal.
Ok. So, I tried using gcloud to change the instance to not need the project passphrase, using
$ cloud compute instances add-metadata [INSTANCE_NAME] --metadata block-project-ssh-keys=TRUE
Same thing.
Please, what the heck am I missing? How do I just permanently remove the need for a passphrase when setting up an instance in datalab from the ssh terminal?
I wouldn't mind using the passphrase so much, but whenever I enter it, the terminal just stops (not hard stop- it just sits there without processing until I ctrl+C and force stop. I can type and enter and whatever, but it doesn't register my passphrase.)
Any help would be greatly appreciated.
FYI, I am setting all this up using a stock Pixelbook. That shouldn't matter since everything is through Google Cloud, but there ya go.
Thanks!
The passphrase isn't tied to your GCP project or Datalab instances in any way.
Instead, it is a property of your local private SSH key. This file usually winds up under ~/.ssh and is named something like google_compute_engine.
Since you mention using a Pixelbook, I assume you are running the datalab connect command from Cloud Shell. In that case, this file is stored inside of your Cloud Shell instance.
Delete that file, and then the next run of datalab connect will generate a new one (for which you can leave the passphrase empty).

Deep Learning Virtual Machine can't run jupyter "No such notebook dir: ''/dsvm/Notebooks''"

I've set up a vm with Deep Learning Virtual Machine (Microsoft Azure).
Normally, I connect to the vm thanks to ssh etc
Then I run jupyter by writing jupyter notebook --no-browser.
But this time I have can't run jupyter notebook because there is this message Bad config encountered during initialization: "No such notebook dir: ''/dsvm/Notebooks''"
How can I fix that ?
Thanks for your help !
I presume you are trying to run Jupyter Notebook and with that goal in mind, I suggest you follow the following steps:
Move your notebook to ~/notebooks/
Find your Pubic IP Address of your VM from Azure Dashboard
Access https://your_public_ip_address:8000 in your web browser and log in using your vm login credentials
You should be able to see all the files you have in ~/notebooks/
I presume this method is defined by Azure for security reasons, to prevent people from having an open port without authentication. Hope this helps!
It worked for me :
jupyter notebook --notebook-dir=/home/$USER/notebooks --no-browser

Global access password for ipython notebook

In ipython notebook I found two (more or less) ways to secure my remote server which is running as my notebook host.
The c.NotebookApp.password option in the config secures the notebook from write access.
The --read-only flag allows not authenticated useres only to view my notebook.
But with point 2. I am not getting warm.
The problem is that it allows anybody to view my notebook. Actually I only want some privileged users to view my notebook. Until now I havn't found any way to do so.
Is there the possibility to secure my notebook globaly with, e.g. a .htaccess file or anything else?
In that case I can give all users the website password and I can change the notebook with my 1.option.
There is no built-in mechanisme for auth and read-only notebook in IPython. And security is complex enough to start adding option for Auth+Read-only at the moment.
You can also install a local copy of nbviewer and/or use nbconvert to export your notebook as static html, and serve using a classical appache/.htaccess scheme.

Resources