I am running an AWS EC2 GPU instance. And I setup iPython notebook on this instance follow the tutorial.
At the last step, I used this command:
sudo ipython notebook --profile=nbserver
to start iPython notebook. It seems OK. The output information is:
[I 14:14:30.214 NotebookApp] Using MathJax from CDN: https://cdn.mathjax.org/mathjax/latest/MathJax.js
[I 14:14:30.230 NotebookApp] Serving notebooks from local directory: /home/ubuntu
[I 14:14:30.230 NotebookApp] 0 active kernels
[I 14:14:30.230 NotebookApp] The IPython Notebook is running at: https://[all ip addresses on your system]:8888/
[I 14:14:30.230 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
However, I use my browser to launch the remote iPython notebook:
https://ec2-54-66-247-201.ap-southeast-2.compute.amazonaws.com:8888/
But I fail on this step. I have no idea. Any suggestion?
You will need to open port 8888 for Inbound traffic in the Security Group associated with your Amazon EC2 instance.
Related
In GCP Vertex AI, I created a Managed Notebook by specifying one of our custom containers which work perfectly with User-Managed Notebook kernels.
The Managed Notebook starts, and Jupyter Lab seems to work without any signs of error.
Unfortunately, if I look at the available kernels in Jupyter Lab, only the default kernels are listed but not my custom kernel.
An activity log entry on the right shows a spinning wheel "Loading kernel from [custom container]" which never disappears.
Taking a look at the terminal,
docker image ls
does not show the custom container either; obviously, it was not even pulled to the Managed Notebook.
If I perform
docker pull [custom container]
in the terminal, to test connectivity to the Artifact Registry then it pulls the container correctly as expected.
However, the custom kernel is still not visible in Jupyter Lab (even after a notebook restart).
I faced the same issue today, and after some experimentation, I found that I haven't fulfilled all the requirements in Vertex AI docs.
One in particular - The Docker container image must support sleep infinity.
And my Dockerfile contained
EXPOSE 8080
ENTRYPOINT [ "jupyter", "lab", "--allow-root", "--ip", "0.0.0.0", "--config", "/opt/jupyter/.jupyter/jupyter_notebook_config.py" ]
To enable sleep infinity I replaced ENTRYPOINT with
ENTRYPOINT ["/bin/sh", "-c", "sleep infinity"]
then the kernelspec was imported, but the notebook wasn't able to connect.
So I removed the ENTRYPOINT entirely and then the kernelspec was imported and the notebook was able to connect successfully.
Hope that helps.
I am connected to AWS AMI uaing ``Puttyand when I doconda env listit shows me all the environments. even the jupyter notebook get started when I dojupyter notebook`, it shows me:
[I 08:00:27.549 NotebookApp] Using EnvironmentKernelSpecManager...
[I 08:00:27.550 NotebookApp] Started periodic updates of the kernel list (every 3 minutes).
[I 08:00:27.778 NotebookApp] Loading IPython parallel extension
[I 08:00:27.808 NotebookApp] JupyterLab extension loaded from /home/ubuntu/anaconda3/lib/python3.7/site-packages/jupyterlab
[I 08:00:27.809 NotebookApp] JupyterLab application directory is /home/ubuntu/anaconda3/share/jupyter/lab
[I 08:00:27.974 NotebookApp] [nb_conda] enabled
[I 08:00:27.975 NotebookApp] Serving notebooks from local directory: /home/ubuntu
[I 08:00:27.975 NotebookApp] The Jupyter Notebook is running at:
[I 08:00:27.975 NotebookApp] http://localhost:8888/
[I 08:00:27.975 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[W 08:00:27.979 NotebookApp] No web browser found: could not locate runnable browser.
[I 08:00:27.979 NotebookApp] Starting initial scan of virtual environments...
[I 08:00:29.943 NotebookApp] Found new kernels in environments: conda_aws_neuron_pytorch_p36, conda_python3, conda_mxnet_latest_p37, conda_aws_neuron_mxnet_p36, conda_pytorch_p36, conda_tensorflow2_latest_p37, conda_tensorflow2_p36, conda_tensorflow_p37, conda_anaconda3, conda_mxnet_p36, conda_aws_neuron_tensorflow_p36, conda_pytorch_latest_p37
How can I access Notebook running on AWS in my Browser?
Your notebook is listening on localhost on the instance on port 8888 (http://localhost:8888). It is accessible only from within instnace, unless you want to fully expose port 8888, which is not a good practice.
The better way is though ssh tunnel. Thus, you would establish an ssh tunnel using putty between your local machine and your instance. There are many tutorials on how to do it in putty. Here is one example:
How to run Jupyter Notebooks on remote server — SSH
In the tutorial you would use port 8888 instead of 1234 which they show. Once the tunnel is up, you can access your notebook in the browser as http://localhost:8888.
Another example on accessing notebooks though ssh tunnel using putty is here.
I was wondering what the 8888 and 8889 number means when I launch a jupyter notebook in my browser (I'm launching the notebook via Anaconda Navigator). I noticed how the number increases by 1 (from 8888 to 8889, to 8891) as I launch more notebooks from my anaconda navigator, but the files I have access to are exactly the same. Why then have different numbers?
Thank you!
You are launching a new process which uses an unused port. The first start will use port 8888, the second (if the process is active) will use port 8889 and so on.
Note: this is just for Jupyter. Other applications may exit with an error code stating the "port is already in use".
Due to a bug in the current shipping Jupyter (6.0.0), I get a missing file error.
It can't find /static/components/react/react-dom.production.min.js
https://github.com/jupyter/notebook/pull/4772#issuecomment-515794823 advises to manually add the file.
However I cannot locate the absolute path, So I don't know where to put the file.
Where is /static/... located on my filesystem?
Full output:
> jupyter notebook
[I 10:44:20.102 NotebookApp] JupyterLab extension loaded from /usr/local/anaconda3/lib/python3.7/site-packages/jupyterlab
[I 10:44:20.102 NotebookApp] JupyterLab application directory is /usr/local/anaconda3/share/jupyter/lab
[I 10:44:20.104 NotebookApp] Serving notebooks from local directory: /Users/pi
[I 10:44:20.104 NotebookApp] The Jupyter Notebook is running at:
[I 10:44:20.104 NotebookApp] http://localhost:8888/?token=586797fb9049c0faea24f2583c4de32c08d45c89051fb07d
[I 10:44:20.104 NotebookApp] or http://127.0.0.1:8888/?token=586797fb9049c0faea24f2583c4de32c08d45c89051fb07d
[I 10:44:20.104 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 10:44:20.110 NotebookApp]
To access the notebook, open this file in a browser:
file:///Users/pi/Library/Jupyter/runtime/nbserver-65385-open.html
Or copy and paste one of these URLs:
http://localhost:8888/?token=586797fb9049c0faea24f2583c4de32c08d45c89051fb07d
or http://127.0.0.1:8888/?token=586797fb9049c0faea24f2583c4de32c08d45c89051fb07d
[E 10:44:21.457 NotebookApp] Could not open static file ''
[W 10:44:21.512 NotebookApp] 404 GET /static/components/react/react-dom.production.min.js (::1) 9.02ms referer=http://localhost:8888/tree?token=BLA
[W 10:44:21.548 NotebookApp] 404 GET /static/components/react/react-dom.production.min.js (::1) 0.99ms referer=http://localhost:8888/tree?token=BLA
find / -path '*/static/components' 2>/dev/null
gets it:
/usr/local/anaconda3/pkgs/notebook-6.0.0-py37_0/lib/python3.7/site-packages/notebook/static/components
/usr/local/anaconda3/lib/python3.7/site-packages/notebook/static/components
The 2>/dev/null part is to stifle warning-lines such as "Permission denied" and "Operation not permitted". It redirects STDERR to /dev/null.
I am trying to use JupyterLab using tmpnb
I want to spawn many JupyterLab instances, just like the way tmpnb does for Jupyter Notebook.
I have created a new docker image by docker build -t jupyterlab2 . command using the following Dockerfile:
FROM jupyter/datascience-notebook
MAINTAINER apr
RUN pip install npm
RUN pip install jupyterlab
RUN jupyter serverextension enable --py jupyterlab
After this I am running the following commands:
export TOKEN=$( head -c 30 /dev/urandom | xxd -p )
docker run --net=host -d -e CONFIGPROXY_AUTH_TOKEN=$TOKEN --name=proxy jupyter/configurable-http-proxy --default-target http://127.0.0.1:9999
docker run --net=host -d -e CONFIGPROXY_AUTH_TOKEN=$TOKEN --name=tmpnb -v /var/run/docker.sock:/docker.sock jupyter/tmpnb python orchestrate.py --allow_origin='*' --image='jupyterlab2' --pool-size=5 --container-user=root --command='jupyter lab --allow-root LabApp.allow_origin="*"'
When I visit the URL http://<ip-address>:8000, I get redirected to http://<ip>:8000/user/sTVKGwH01uoQ, but this shows 404.
I also tried visiting http://<ip>:8000/user/sTVKGwH01uoQ/lab but this too gives 404.
Logs for 1 instance are below:
Set username to: jovyan
usermod: no changes
Set jovyan GID to: 100
Execute the command: jupyter lab --allow-root --port 8888 --ip=0.0.0.0 --LabApp.allow_origin=*
[I 09:05:52.598 LabApp] Writing notebook server cookie secret to /home/jovyan/.local/share/jupyter/runtime/notebook_cookie_secret
[I 09:05:54.689 LabApp] JupyterLab alpha preview extension loaded from /opt/conda/lib/python3.6/site-packages/jupyterlab
[I 09:05:54.694 LabApp] Serving notebooks from local directory: /home/jovyan
[I 09:05:54.694 LabApp] 0 active kernels
[I 09:05:54.694 LabApp] The Jupyter Notebook is running at:
[I 09:05:54.694 LabApp] http://0.0.0.0:8888/?token=584fc5114d037ad23296ca8284ea1074b220d058018cb2c4
[I 09:05:54.694 LabApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 09:05:54.695 LabApp]
Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
http://0.0.0.0:8888/?token=584fc5114d037ad23296ca8284ea1074b220d058018cb2c4
[I 09:05:57.142 LabApp] 302 GET /user/1BhE9UZ2gg5o/ (172.17.0.1) 0.54ms
[W 09:05:57.144 LabApp] 404 GET /user/1BhE9UZ2gg5o (172.17.0.1) 1.45ms referer=None
[I 09:05:57.347 LabApp] 302 GET /user/1BhE9UZ2gg5o/ (172.17.0.1) 0.56ms
[W 09:05:57.350 LabApp] 404 GET /user/1BhE9UZ2gg5o (172.17.0.1) 1.44ms referer=None
[I 09:05:57.553 LabApp] 302 GET /user/1BhE9UZ2gg5o/ (172.17.0.1) 0.55ms
[W 09:05:57.556 LabApp] 404 GET /user/1BhE9UZ2gg5o (172.17.0.1) 1.41ms referer=None
[I 09:05:57.767 LabApp] 302 GET /user/1BhE9UZ2gg5o/ (172.17.0.1) 2.80ms
[W 09:05:57.773 LabApp] 404 GET /user/1BhE9UZ2gg5o (172.17.0.1) 3.44ms referer=None
[I 09:05:57.978 LabApp] 302 GET /user/1BhE9UZ2gg5o/ (172.17.0.1) 0.56ms
[W 09:05:57.981 LabApp] 404 GET /user/1BhE9UZ2gg5o (172.17.0.1) 1.46ms referer=None
[I 09:05:58.184 LabApp] 302 GET /user/1BhE9UZ2gg5o/ (172.17.0.1) 0.55ms
[W 09:05:58.187 LabApp] 404 GET /user/1BhE9UZ2gg5o (172.17.0.1) 1.42ms referer=None
[I 09:05:58.391 LabApp] 302 GET /user/1BhE9UZ2gg5o/ (172.17.0.1) 0.56ms
[W 09:05:58.394 LabApp] 404 GET /user/1BhE9UZ2gg5o (172.17.0.1) 2.05ms referer=None
[W 09:06:18.518 LabApp] 404 GET /user/1BhE9UZ2gg5o/tree (172.17.0.1) 1.61ms referer=http://52.71.15.52:8000/
[W 09:06:27.502 LabApp] 404 GET /user/1BhE9UZ2gg5o/lab (172.17.0.1) 2.51ms referer=None
[W 09:07:20.568 LabApp] 404 GET /user/1BhE9UZ2gg5o/lab (172.17.0.1) 2.28ms referer=None
I looked at an issue related to JupyterHub, which looked very similar. The 404 error page is same for me too. I tried some random things with start.sh too, but no luck.
Is it even possible to run JupyterLab using tmpnb? If no, then what are the other tools that I can use the achieve the same purpose?
The base URL must be set, otherwise the /user/... routes won't map to the right things. This is the --NotebookApp.base_url={base_path} part in the all of the example commands in the tmpnb README. These look like:
python orchestrate.py --command='jupyter notebook --no-browser \
--port {port} --ip=0.0.0.0 --NotebookApp.base_url={base_path} \
--NotebookApp.port_retries=0'
So a JupyterLab equivalent would be:
python orchestrate.py --command='jupyter lab --no-browser \
--port {port} --ip=0.0.0.0 --NotebookApp.base_url={base_path} \
--NotebookApp.port_retries=0'
All of those apply with jupyterlab as well, so probably the only arg you want to replace is notebook with lab. At the same time, you don't need to change the default command at all, because if the lab extension is installed, jupyterlab is available at the /lab URL when you start jupyter notebook. You can see this right now by replacing /tree with /lab on any existing tmpnb.org URL.