= Jupyter Notebook = The ​[https://jupyter.org/ Jupyter Notebook] is a web application that allows you to create and share documents that contain live code, equations, visualizations, and explanatory text. == Option 1 == === 1. Getting started === On Cypress, download the script. {{{ git clone https://gitlab.tulane.edu/fuji/launchjupyter.git }}} Copy LaunchJupyter.sh to the directory where you want to run the Jupyter Notebook, and edit it to customize the resource request to your needs. The default settings are shown below: {{{ #SBATCH --qos=normal # Quality of Service #SBATCH --partition=centos7 # partition #SBATCH --job-name=jupyter # Job Name #SBATCH --time=8:00:00 # WallTime #SBATCH --nodes=1 # Number of Nodes #SBATCH --ntasks-per-node=1 # Number of tasks (MPI processes) #SBATCH --cpus-per-task=20 # Number of threads per task (OMP threads) #SBATCH --mem=128000 # Request 128GB RAM }}} === 2. Submit a job === {{{ sbatch LaunchJupyter.sh }}} You can log out after submitting the job. You will receive an email once the job becomes active. 3. Read Jupyter Notebook Access Information Email Once the job becomes active, you will receive an email like below: {{{ Jupyter is running at cypress01-058 token: 38e3c6cdf28b9d691677882cfcf62fbd217d35e1de7cc909 Open a terminal and run the following command to create an SSH tunnel: ssh -L 8888:127.0.0.1:8888 -J userid@cypress.tulane.edu cypress01-058 Copy and paste below to your web browser to access Jupyter Notebook: http://127.0.0.1:8888/?token=38e3c6cdf28b9d691677882cfcf62fbd217d35e1de7cc909 }}} === 4. Create an SSH Tunnel === Open a terminal and run the command in the email, for example, {{{ ssh -L 8888:127.0.0.1:8888 -J userid@cypress.tulane.edu cypress01-058 }}} This will create an SSH tunnel from your local computer to the Cypress computing node. You may need to type a password to login Cypress. === 5. Access Jupyter Notebook === After logging in, keep the terminal open. Copy and paste the URL from the email into your web browser, or click the link to access the Jupyter Notebook. ==== When SSH connection lost ==== When your SSH tunnel session is disconnected, you can still access your Jupyter Notebook session as long as the job is still running. If this happens, recreate the SSH tunnel and reload your web browser or reconnect using the original URL. ==== Quit Jupyter Notebook Session ==== Click the “Quit” button located at the upper-right corner of the Jupyter Notebook interface. == Option 2 == 1. Login to Cypress with port-forwarding {{{ [user@local ~]$ ssh -L 8888:127.0.0.1:12345 userID@cypress.tulane.edu }}} '''Replace '12345' with a big number you like'''. 2. On Cypress, move to your desired directory (see the [[BasicLinuxComands#cd|cd]] command) for containing either existing or future notebook files - usually with file extension '''.ipynb'''. 3. Start an interactive session with port-forwarding. '''Replace '12345' with the same big number you specified above'''. If you need Centos 7 with glibc 2.17, then include in your idev command the idev parameter '''--partition=centos7'''. (See [[using#Requestingpartitioncentos7withglibc2.17|Centos 7/glibc 2.17]] and [[using#Options|idev options]].) {{{ [userID@cypress2 Python]$ idev --port=12345:8888 --partition=centos7 -t 8 -c 1 Requesting 1 node(s) task(s) to normal queue of defq partition 1 task(s)/node, 1 cpu(s)/task, 2 MIC device(s)/node Time: 08 (hr) 00 (min). Submitted batch job 282455 JOBID=282455 begin on cypress01-093 --> Creating interactive terminal session (login) on node cypress01-093. --> You have 08 (hr) 00 (min). --> Assigned Host List : /tmp/idev_nodes_file_fuji Last login: Wed Aug 24 11:46:09 2016 from cypress2.cm.cluster }}} At this point, if you encounter a message like below: {{{ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ }}} You need to log off from the computing node, delete the ~/.ssh/known_hosts file, and then try again. 4. Load the module and start jupyter notebook server. {{{ [userID@cypress01-093 Python]$ module load anaconda3/2023.07 [userID@cypress01-093 Python]$ jupyter notebook --port=8888 --no-browser }}} 5. Examine the resulting output in your terminal window and locate any occurrence of a string starting with '''http:^^/^^/''' and including a parameter named '''token''' assigned to a string of hexadecimal digits (0-9,a-f). The former string is a URL for your own personal use to authenticate the current notebook session. {{{ http://localhost:8888/?token=9a84272b92849f6d560e0068de58a4b2a4ab0cb00387bf36 (example only) }}} {{{ http://127.0.0.1:8888/?token=9a84272b92849f6d560e0068de58a4b2a4ab0cb00387bf36 (example only) }}} 6. Using your own personal URL from above from your terminal window (not the example above), copy and paste that URL to the address field in your local web browser, and press and observe the notebook web page in your browser. '''Note: your ''jupyter notebook'' session will be killed when the idev-session time exceeds the walltime limit (that is 8 hours in the example above).''' Ctrl+c to shutdown ''jupyter notebook''.