Skip to content

Instantly share code, notes, and snippets.

@zorbax
Last active June 20, 2022 12:09
Show Gist options
  • Select an option

  • Save zorbax/7073df9fc551085d28ade925441a1042 to your computer and use it in GitHub Desktop.

Select an option

Save zorbax/7073df9fc551085d28ade925441a1042 to your computer and use it in GitHub Desktop.

REMOTE

1a. Create a conda environment for R and Julia to avoid conflict with local installation

conda install -yc conda-forge mamba

mamba create -n jupyteR -yc r -c conda-forge \
    r-essentials r-base ipykernel jupyterlab r-irkernel
# Install Julia and the Jupyter-Julia kernel

mkdir $HOME/bin && cd "$_" 
wget https://julialang-s3.julialang.org/bin/linux/x64/1.6/julia-1.6.4-linux-x86_64.tar.gz
tar zxvf julia-1.6.4-linux-x86_64.tar.gz && rm julia-1.6.4-linux-x86_64.tar.gz

echo 'export PATH=$PATH:$HOME/bin/julia-1.6.4/bin' >> ~/.bash_profile
source $HOME/.bash_profile

julia -e 'import Pkg; Pkg.update(); Pkg.add("IJulia")'

2. Configure a password to avoid using Token

You only need to do this the first time

source activate jupyteR

jupyter lab --generate-config
jupyter lab password

3. Launch jupyter

# Non-available ports in Hulk local address
netstat -lntu | awk 'NR>2 {print $4}' | grep -E '0.0.0.0:' | sed 's/.*://' | sort -n | uniq

# Select an available port in a range of 8800-8899

# Using a terminal multiplexer
tmux -u new -s julia

srun -J notebook -N 1 \
    --ntasks-per-node=1 --pty $(which bash) -c \
    "jupyter lab --ip 0.0.0.0 \
        --port 8887 --no-browser \
        --notebook-dir=/emc/cbmr/users/$USER/notebooks" 

# Tmux dettach
# CTRL + B + D

conda deactivate

4. Get the local IP from the network using VPN

hostname -I

For me, this is the local address of the server to use through ssh: 10.128.7.72. You can use 'hulk' as well.

LOCAL

5. Open a browser tab with the address, introduce your password.

10.128.7.72:8888/lab

Or:

hulk:8888/lab

At the moment the previous step only works with Pulse Secure. However, you can use the Malte's solution, tunneling through Porus

6. Connect to server using SSH via Porus

ssh -o TCPKeepAlive=no \
    -o ServerAliveCountMax=20 \
    -o ServerAliveInterval=15 \
    -N -L 8000:10.128.7.72:8888 [email protected]

Or

ssh -o TCPKeepAlive=no \
    -o ServerAliveCountMax=20 \
    -o ServerAliveInterval=15 \
    -N -L 8000:hulk:8888 [email protected]
@zorbax
Copy link
Author

zorbax commented Oct 25, 2021

If you don't want the local version of conda you can install your own:

mkdir -p $HOME/bin && cd "$_" || exit
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh -b -p $HOME/bin/miniconda3
rm Miniconda3-latest-Linux-x86_64.sh

### Add miniconda bin path to $PATH
echo -e 'export PATH=$HOME/bin/miniconda3/bin:$PATH' >>$HOME/.bash_profile

source $HOME/.bashrc

### Add extra channels to Conda
cat <<EOF >>$HOME/.condarc
channels:
  - conda-forge
  - bioconda
  - defaults
EOF

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment