Wiki source code of Starting Jupyter or Tensorflow
Last modified by Jan Rhebergen on 2022/02/06 13:31
Hide last authors
| author | version | line-number | content |
|---|---|---|---|
![]() |
1.1 | 1 | = How to start Jupyter = |
| 2 | |||
| 3 | |||
| 4 | (% class="box infomessage" %) | ||
| 5 | ((( | ||
| 6 | **NB**: | ||
![]() |
1.2 | 7 | |
| 8 | * port numbers used below depend on the user! (see [[here>>doc:UOG.Technical Documentation.Nginxproxymanager.WebHome]]) | ||
| 9 | * this section requires a preinstalled (configures) ##conda## data-science environmen! | ||
![]() |
1.1 | 10 | ))) |
| 11 | |||
| 12 | |||
| 13 | == Start == | ||
| 14 | |||
| 15 | 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): | ||
| 16 | |||
| 17 | (% class="box" %) | ||
| 18 | ((( | ||
| 19 | ##ssh username@dashy -p 8082## | ||
| 20 | ))) | ||
| 21 | |||
| 22 | Now you will be asked for the password (this is Beethoven's password), enter the password. | ||
| 23 | |||
| 24 | 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. | ||
| 25 | |||
| 26 | In the browser local on Safari or Chrome the following must now be entered: | ||
| 27 | |||
![]() |
1.2 | 28 | [[http:~~/~~/117.204.107.243:8887/>>url:http://116.203.106.242:8887/]] |
![]() |
1.1 | 29 | |
| 30 | The Jupyter environment will now open. | ||
| 31 | |||
| 32 | == First time access == | ||
| 33 | |||
| 34 | 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: | ||
| 35 | |||
| 36 | http://beethoven:8887/?Token= | ||
| 37 | |||
| 38 | 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. | ||
| 39 | |||
| 40 | The Jupyter environment will now be opened and ready for use. | ||
| 41 | |||
| 42 | == Shut down == | ||
| 43 | |||
| 44 | To exit, you can manually close the browser. | ||
| 45 | |||
| 46 | 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##. | ||
| 47 | |||
| 48 | == Scripts == | ||
| 49 | |||
| 50 | === Jupyter === | ||
| 51 | |||
| 52 | 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. | ||
| 53 | |||
| 54 | (% class="box" %) | ||
| 55 | {{{#!/bin/bash | ||
| 56 | source $HOME/miniconda3/etc/profile.d/conda.sh | ||
| 57 | #JBR Activate the desired conda environment (edit if needed). | ||
| 58 | conda activate data-science | ||
| 59 | echo "switching to environment:" | ||
| 60 | echo $CONDA_DEFAULT_ENV | ||
| 61 | echo -e "\nStarting Jupyter,...." | ||
| 62 | echo "When done with your work don't forget to shutdown Jupyter using the web-browser! (Files>Shut Down)" | ||
| 63 | echo "This script can be terminated using Ctrl-C" | ||
| 64 | echo -e "Manually stop/kill hanging processes (if any).\n" | ||
| 65 | #JBR If not properly shutdown use 'ps' and 'kill' to terminate the jupyter-lab process | ||
| 66 | #JBR Remember we reserve port 8888 for the local instance of Jupyter | ||
| 67 | echo "Browse to http://116.203.106.242:8883 to see your notebooks" | ||
| 68 | echo -e "Then copy & paste the token from here and create your own password (only once)\n" | ||
| 69 | #JBR_OFF jupyter-lab --ip 0.0.0.0 --port 8883 --no-browser & | ||
| 70 | jupyter-lab --ip 0.0.0.0 --port 8883 --no-browser | ||
| 71 | #JBR remember to once: ssh-copy-id guul@dashy | ||
![]() |
1.2 | 72 | #JBR_OFF ssh guul@117.204.107.243 -N -R \*:8883:localhost:8883 |
![]() |
1.1 | 73 | }}} |
| 74 | |||
| 75 | A slightly "better/flexible" version: | ||
| 76 | |||
| 77 | (% class="box" %) | ||
| 78 | {{{#!/bin/bash | ||
| 79 | #JBRv a shell proedure to change to the desired datas science directory alternately a . or source command would also work | ||
| 80 | dshome () { | ||
| 81 | cd $HOME/Data-Science | ||
| 82 | } | ||
| 83 | |||
| 84 | source $HOME/miniconda3/etc/profile.d/conda.sh | ||
| 85 | dshome | ||
| 86 | |||
| 87 | #JBR Activate the desired conda environment (edit if needed). | ||
| 88 | conda activate data-science | ||
| 89 | |||
| 90 | echo -e "\nStarting Jupyter,...." | ||
| 91 | echo "When done with your work don't forget to shutdown Jupyter using the web-browser! (Files>Shut Down)" | ||
| 92 | echo "This script can be terminated using Ctrl-C" | ||
| 93 | echo -e "Manually stop/kill hanging processes (if any).\n" | ||
| 94 | #JBR If not properly shutdown use 'ps' and 'kill' to terminate the jupyter-lab process | ||
| 95 | #JBR Remember we reserve port 8888 for the local instance of Jupyter | ||
![]() |
1.2 | 96 | echo "Browse to http://117.204.107.243:8889 to see your notebooks" |
![]() |
1.1 | 97 | echo -e "Then copy & paste the token from here and create your own password (only once)\n" |
| 98 | jupyter-lab --ip 0.0.0.0 --port 8889 --no-browser | ||
| 99 | #JBR_OFF jupyter-lab --ip 0.0.0.0 --port 8889 --no-browser & | ||
![]() |
1.2 | 100 | #JBR_OFF ssh jan@117.204.107.243 -N -R \*:8889:localhost:8889 |
![]() |
1.1 | 101 | }}} |
| 102 | |||
| 103 | === Tensorman === | ||
| 104 | |||
| 105 | Here's ##my_tensorman_plain.sh## which does not start ##jupyter##: | ||
| 106 | |||
| 107 | (% class="box" %) | ||
| 108 | {{{#!/bin/sh | ||
| 109 | cd $HOME/project | ||
| 110 | tensorman =jupyter-lab-gpu run -p 8889:8889 --gpu --python3 --name $USER bash | ||
| 111 | }}} | ||
| 112 | |||
| 113 | Here's the versioen that also starts ##jupyter## which usually is what we want: | ||
| 114 | |||
| 115 | (% class="box" %) | ||
| 116 | {{{#!/bin/sh | ||
| 117 | cd $HOME/project | ||
| 118 | tensorman =jupyter-lab-gpu run -p 8889:8889 --gpu --python3 --jupyter --name $USER bash | ||
| 119 | }}} |
