Technical Documentation - Starting Jupyter or Tensorflow

Page / - last modified by Jan Rhebergen on 2022/02/06 13:31

Starting Jupyter or Tensorflow

last modified by Jan Rhebergen

on 2022/02/06 13:31

Table of Contents

How to start Jupyter

Start

First time access

Shut down

Scripts

Jupyter

Tensorman

How to start Jupyter

NB:

port numbers used below depend on the user! (see here)

this section requires a preinstalled (configures) conda data-science environmen!

Start

Open the terminal (on Windows: Start, then cmd and press Enter). When the terminal window opens, type the following command (replace username with own name):

ssh username@dashy -p 8082

Now you will be asked for the password (this is Beethoven's password), enter the password.

When the password has been entered correctly, you can see that Beethoven is now logged in by (base) username@beethoven. To start the Jupyter environment, enter the following command: my_jupyter.sh and press Enter.

In the browser local on Safari or Chrome the following must now be entered:

http://117.204.107.243:8887/

The Jupyter environment will now open.

First time access

If it is the first time to access this environment, a token must be entered at the top of the web page. The Token (a combination of numbers and/or letters) can be found in the Terminal here:

http://beethoven:8887/?Token=

You can copy the number (after Token=) from the terminal and paste it at the top of the newly opened browser Jupyter page. Paste the number of the Token and press Log in or the Enter key.

The Jupyter environment will now be opened and ready for use.

Shut down

To exit, you can manually close the browser.

In the terminal, use Ctrl+C and you will see username@beethoven again, after this you type "exit" which will log you out of dashy.

Scripts

Jupyter

This is the my_jupyter.sh shell script used to start a Jupyter session. Every user has a slightly different one due to teh different port number. To let this script remain active even after you log out one can use screen. Just start screen and click through the initial message until you get a command prompt again. Then start the script and detach the session using the Ctrl-A D key combination.

#!/bin/bash

source $HOME/miniconda3/etc/profile.d/conda.sh

#JBR Activate the desired conda environment (edit if needed).

conda activate data-science

echo "switching to environment:"

echo $CONDA_DEFAULT_ENV

echo -e "\nStarting Jupyter,...."

echo "When done with your work don't forget to shutdown Jupyter using the web-browser! (Files>Shut Down)"

echo "This script can be terminated using Ctrl-C"

echo -e "Manually stop/kill hanging processes (if any).\n"

#JBR If not properly shutdown use 'ps' and 'kill' to terminate the jupyter-lab process

#JBR Remember we reserve port 8888 for the local instance of Jupyter

echo "Browse to http://116.203.106.242:8883 to see your notebooks"

echo -e "Then copy & paste the token from here and create your own password (only once)\n"

#JBR_OFF jupyter-lab --ip 0.0.0.0 --port 8883 --no-browser &

jupyter-lab --ip 0.0.0.0 --port 8883 --no-browser

#JBR remember to once: ssh-copy-id guul@dashy

#JBR_OFF ssh guul@117.204.107.243 -N -R \*:8883:localhost:8883

A slightly "better/flexible" version:

#!/bin/bash

#JBRv a shell proedure to change to the desired datas science directory alternately a . or source command would also work

dshome () {

cd $HOME/Data-Science

}

source $HOME/miniconda3/etc/profile.d/conda.sh

dshome

#JBR Activate the desired conda environment (edit if needed).

conda activate data-science

echo -e "\nStarting Jupyter,...."

echo "When done with your work don't forget to shutdown Jupyter using the web-browser! (Files>Shut Down)"

echo "This script can be terminated using Ctrl-C"

echo -e "Manually stop/kill hanging processes (if any).\n"

#JBR If not properly shutdown use 'ps' and 'kill' to terminate the jupyter-lab process

#JBR Remember we reserve port 8888 for the local instance of Jupyter

echo "Browse to http://117.204.107.243:8889 to see your notebooks"

echo -e "Then copy & paste the token from here and create your own password (only once)\n"

jupyter-lab --ip 0.0.0.0 --port 8889 --no-browser

#JBR_OFF jupyter-lab --ip 0.0.0.0 --port 8889 --no-browser &

#JBR_OFF ssh jan@117.204.107.243 -N -R \*:8889:localhost:8889

Tensorman

Here's my_tensorman_plain.sh which does not start jupyter:

#!/bin/sh

cd $HOME/project

tensorman =jupyter-lab-gpu run -p 8889:8889 --gpu --python3 --name $USER bash

Here's the versioen that also starts jupyter which usually is what we want:

#!/bin/sh

cd $HOME/project

tensorman =jupyter-lab-gpu run -p 8889:8889 --gpu --python3 --jupyter --name $USER bash