You can run the notebook in an interactive session. Change the username in step 0 and the port in step 10. The port range should be [5900-5999]. For access, connect to the ETH network via VPN/WiFi.
```
# Step 0: Connect to a D-ITET host
ssh hodl_XXXfs24@tik42x
# Step 1: Change working directory to net_scratch
cd /usr/itetnas04/data-scratch-01/$USER/data
# Step 2: Set cluster to Snowflake
# https://computing.ee.ethz.ch/Services/SLURM-Snowflake#Setting_environment
export SLURM_CONF=/home/sladmsnow/slurm/slurm.conf
# Step 3: Start interactive job
# https://computing.ee.ethz.ch/Services/SLURM-Snowflake#Job_submission
srun --pty bash -i
# Step 4: Assign TMPDIR to local scratch
# https://computing.ee.ethz.ch/Programming/Languages/Conda#Change_TMPDIR
TMPDIR=/scratch/$USER/tmp && mkdir -p $TMPDIR && export TMPDIR
# Step 5: Assign PIP cache to local scratch
# https://computing.ee.ethz.ch/Programming/Languages/Python#pip_cache
PIP_CACHE_DIR=/scratch/$USER/pip_cache && mkdir -p $PIP_CACHE_DIR && export PIP_CACHE_DIR
# Step 6: Use net_scratch to install micromamba and python environments
# see https://computing.ee.ethz.ch/Services/NetScratch
MAMBA_ROOT_PREFIX="/usr/itetnas04/data-scratch-01/${USER}/data/micromamba"
micromamba_installer_url='https://micro.mamba.pm/api/micromamba/linux-64/latest'
env_name='jupyter_notebook'
# Step 7: Installation with pytorch and Cuda matching GPU driver in cluster:
# Takes more than 5'
python_packages='notebook matplotlib scipy sqlite pytorch torchvision pytorch-cuda=11.8'
conda_channels='--channel conda-forge --channel pytorch --channel nvidia'
mkdir -v -p "${MAMBA_ROOT_PREFIX}" &&
cd "${MAMBA_ROOT_PREFIX}" &&
# Download latest Micromamba (static linked binary)
wget -O- "${micromamba_installer_url}" |
# Extract Micromamba
tar -xvj bin/micromamba &&
# Set base path for Micromamba
export MAMBA_ROOT_PREFIX &&
# Initialize Micromamba
eval "$(${MAMBA_ROOT_PREFIX}/bin/micromamba shell hook --shell=bash)" &&
# Create the python environment for the course
micromamba create --yes --name ${env_name} ${python_packages} ${conda_channels} &&
# Show how to initialize micromamba
echo &&
echo "Activate environment ${env_name}:" &&
echo " micromamba activate ${env_name}"
cd ..
# Step 8: Initialize micromamba
export MAMBA_ROOT_PREFIX=$PWD/micromamba
eval "$($MAMBA_ROOT_PREFIX/bin/micromamba shell hook --shell=bash)"
# Step 9: Activate environment
micromamba activate jupyter_notebook
# Step 10: Start jupyter notebook
jupyter notebook --no-browser --port XXXX --ip $(hostname -f)
```
When you are finished with the notebook, press ctrl+c (closing the notebook), ctrl+d (exiting the env) and ctrl+d (returning the GPU into the common pool).
Step 7 intsalls everything, you do not need to run it when you are logging on for the second time.