Skip to content

Instantly share code, notes, and snippets.

@33eyes
Last active April 9, 2024 08:56

Revisions

  1. 33eyes revised this gist Apr 18, 2018. 1 changed file with 13 additions and 5 deletions.
    18 changes: 13 additions & 5 deletions jupyter_notebook_w_nohup.md
    Original file line number Diff line number Diff line change
    @@ -12,8 +12,10 @@ nohup jupyter notebook &
    (the & sends the process to run in the background, so that the terminal window can be used)

    ## Tunnel into the remote jupyter notebook from local
    In the local terminal, run:
    `ssh awsgpu -NL 8157:localhost:8888 ubuntu@11.111.111.11`
    In the local terminal, run:
    ```
    ssh awsgpu -NL 8157:localhost:8888 ubuntu@11.111.111.11
    ```
    replacing `awsgpu` with remote server ssh login,
    `8157` with a free local port,
    `8888` with the port used by jupyter notebook on the remote server (usually it's 8888),
    @@ -23,13 +25,19 @@ and `11.111.111.11` with remote server IP.
    Since we now have a jupyter notebook running in the background, we can't stop the notebook
    by closing the terminal window or `Ctrl C`. Here are the steps to stop it.
    - check what jupyter notebooks are running:
    `jupyter notebook list`
    ```
    jupyter notebook list
    ```
    (note which ports are being used)
    - find which process IDs (PIDs) are being run on the port used by the jupyter notebook(s):
    `netstat -tulpn`
    ```
    netstat -tulpn
    ```
    Look for processes that are running on port 8888 (or whichever port was listed in the step above),
    and note the PID.
    - now kill the process(es):
    `kill 2759`
    ```
    kill 2759
    ```
    replace `2759` with the PID from the step above.

  2. 33eyes revised this gist Apr 18, 2018. 1 changed file with 5 additions and 3 deletions.
    8 changes: 5 additions & 3 deletions jupyter_notebook_w_nohup.md
    Original file line number Diff line number Diff line change
    @@ -5,12 +5,14 @@ even if you get disconnected from it (any running notebook code continues to run
    without interruption, and just needs to be re-tunneled into).

    ## Start jupyter notebook on remote server
    In the remote server terminal, run:
    `nohup jupyter notebook &`
    In the remote server terminal, run:
    ```
    nohup jupyter notebook &
    ```
    (the & sends the process to run in the background, so that the terminal window can be used)

    ## Tunnel into the remote jupyter notebook from local
    In the local terminal, run:
    In the local terminal, run:
    `ssh awsgpu -NL 8157:localhost:8888 ubuntu@11.111.111.11`
    replacing `awsgpu` with remote server ssh login,
    `8157` with a free local port,
  3. 33eyes created this gist Apr 18, 2018.
    33 changes: 33 additions & 0 deletions jupyter_notebook_w_nohup.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    # Running jupyter notebook with nohup
    This is helpful when running jupyter notebook on remote server (AWS) and tunneling into it,
    because with nohup the notebook process continues to run on the server
    even if you get disconnected from it (any running notebook code continues to run on the server
    without interruption, and just needs to be re-tunneled into).

    ## Start jupyter notebook on remote server
    In the remote server terminal, run:
    `nohup jupyter notebook &`
    (the & sends the process to run in the background, so that the terminal window can be used)

    ## Tunnel into the remote jupyter notebook from local
    In the local terminal, run:
    `ssh awsgpu -NL 8157:localhost:8888 ubuntu@11.111.111.11`
    replacing `awsgpu` with remote server ssh login,
    `8157` with a free local port,
    `8888` with the port used by jupyter notebook on the remote server (usually it's 8888),
    and `11.111.111.11` with remote server IP.

    ## Stop the remote jupyter notebook
    Since we now have a jupyter notebook running in the background, we can't stop the notebook
    by closing the terminal window or `Ctrl C`. Here are the steps to stop it.
    - check what jupyter notebooks are running:
    `jupyter notebook list`
    (note which ports are being used)
    - find which process IDs (PIDs) are being run on the port used by the jupyter notebook(s):
    `netstat -tulpn`
    Look for processes that are running on port 8888 (or whichever port was listed in the step above),
    and note the PID.
    - now kill the process(es):
    `kill 2759`
    replace `2759` with the PID from the step above.