Skip to content

Hsc 2025 #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions cell_classification/pytorch/train_infection_classifier.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@
" image_for_visualization = image.transpose((1, 2, 0))\n",
" image_for_visualization[..., -1] = image_for_visualization[..., 1]\n",
" image_for_visualization[..., 1] *= 0.0\n",
" viewer.add_image(image_for_visualization, name=f\"sample{index}-{label_name}\")\n",
" viewer.add_image(image_for_visualization, name=f\"sample{index}-{label_name}\", rgb=True)\n",
"\n",
"# This enables a grid-view in napari, so that you will see all images side by side.\n",
"viewer.grid.enabled = True"
Expand Down Expand Up @@ -1273,9 +1273,9 @@
"sourceType": "notebook"
},
"kernelspec": {
"display_name": "micro_sam",
"display_name": "Python 3",
"language": "python",
"name": "micro_sam"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -1287,7 +1287,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
"version": "3.13.3"
}
},
"nbformat": 4,
Expand Down
170 changes: 170 additions & 0 deletions cell_segmentation/micro_sam/pretrained_segmentation.ipynb

Large diffs are not rendered by default.

200 changes: 200 additions & 0 deletions container_cca.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
Bootstrap: docker
From: rockylinux/rockylinux:8

%files
/sw/viz/jupyterhub-nhr/jupyter-containers/data/gwdg.repo /etc/yum.repos.d/gwdg.repo
/sw/viz/jupyterhub-nhr/jupyter-containers/data/Xorg.0.log /var/log/Xorg.0.log
/sw/viz/jupyterhub-nhr/jupyter-containers/data/update-desktop-files.sh /usr/local/share/update-desktop-files.sh
/sw/viz/jupyterhub-nhr/jupyter-containers/data/audio-proxy.sh /usr/local/bin/audio-proxy.sh
/sw/viz/jupyterhub-nhr/jupyter-containers/data/audio-plugin.js /usr/local/share/audio-plugin.js

%post

curl -o /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8 https://ftp.gwdg.de/pub/linux/fedora/epel/RPM-GPG-KEY-EPEL-8

# Configure repositories
rm -f /etc/yum.repos.d/[^g]*

echo "max_parallel_downloads=15" >> /etc/dnf/dnf.conf
echo "exclude=rocky-repos rocky-release" >> /etc/dnf/dnf.conf
echo "8.10" > /etc/dnf/vars/releasever
echo "8" > /etc/dnf/vars/majorver
echo "pub/linux/rocky" > /etc/dnf/vars/contentdir

dnf update -y

# Create slurmuser
groupadd -g 450 slurm
useradd -m -c "SLURM workload manager" -d /var/lib/slurm -u 450 -g slurm -s /bin/bash slurm

# Install basic system tools
dnf install -y make gcc wget curl file perl tcl tcsh openssh htop Lmod git tmux \
openssl ca-certificates python3.11-pip python3.11-setuptools-rust

# Install jupyter dependencies (jupyterhub, jupyter-remote-desktop-proxy, websockify)
# Unfortunately, we have to build websockify manually to get rebind.so, as that is not distributed.
python3.11 -m venv /opt/jupyter
export PATH=/opt/jupyter/bin:$PATH

# websockify
build_dir=/root/websockify
mkdir $build_dir
wget https://github.com/novnc/websockify/archive/refs/tags/v0.12.0.tar.gz
tar --extract --strip-components 1 --directory $build_dir --file v0.12.0.tar.gz
rm v0.12.0.tar.gz
python3.11 -m pip install $build_dir

# Compile rebind.so
pushd $build_dir
make
cp -v rebind.so /opt/jupyter/lib
cp -v rebind.so /usr/local/lib
popd
rm -rf $build_dir

python3.11 -m pip install 'jupyter-remote-desktop-proxy>=3.0.1' jupyterhub
install_dir=$(pip show jupyter-remote-desktop-proxy| awk '/^Location:/ { print $2 }')

ln -s /opt/jupyter/bin/jupyterhub-singleuser /usr/local/bin
ln -s /opt/jupyter/bin/websockify /usr/local/bin

# Link xstartup file
ln -s /sw/scc-sw /opt/sw
ln -sf /sw/viz/jupyterhub-nhr/gwdg-custom-datascience-notebook/desktop.xstartup ${install_dir}/jupyter_remote_desktop_proxy/share/xstartup


# Installing the nvidia drivers and libraries
#NVIDIA_VER="550.144.03-1.el8" # remember to also adjust kmod-nvidia
NVIDIA_VER="550.163.01-1.el8" # remember to also adjust kmod-nvidia

mkdir /root/nvidia-rpms
pushd /root/nvidia-rpms
curl -O https://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/nvidia-driver-${NVIDIA_VER}.x86_64.rpm
curl -O https://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/nvidia-driver-libs-${NVIDIA_VER}.x86_64.rpm
curl -O https://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/nvidia-driver-cuda-${NVIDIA_VER}.x86_64.rpm
curl -O https://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/nvidia-driver-cuda-libs-${NVIDIA_VER}.x86_64.rpm
curl -O https://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/nvidia-kmod-common-${NVIDIA_VER}.noarch.rpm
curl -O https://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/kmod-nvidia-550.163.01-4.18.0-553.50.1-550.163.01-3.el8_10.x86_64.rpm
curl -O https://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/nvidia-persistenced-${NVIDIA_VER}.x86_64.rpm

dnf install -y *.rpm
popd
rm -rf /root/nvidia-rpms


# Install VNC requirements (turbovnc, dbus, virtualgl, mesa, etc)
dnf install -y tigervnc-server tigervnc-server-module dbus-x11 VirtualGL \
libevent libXrender libxcrypt glx-utils mesa-dri-drivers mesa-libGLU libglvnd-opengl libglvnd-egl

# Install GNOME desktop environment (and GUI programs)
dnf group list
dnf group list --hidden
dnf groupinstall -y "base-x" "GNOME Desktop Environment" "GNOME Applications"

dnf install -y qt5-qtbase-gui icu libicu50 emacs vim-enhanced nedit neovim geany gedit firefox fakeroot bash-completion bind-utils telnet vlc
dnf install -y atk fftw-libs libatomic libgfortran libnsl libXScrnSaver mesa-libOSMesa sqlite strace xcb-util-cursor xdg-utils PackageKit
dnf install -y vlc vlc-extras qt5-qtsvg

# VDPAU drivers (used for encoding videos, not actually needed for the VirtualGL image pipeline)
dnf install -y libvdpau mesa-vdpau-drivers libva-vdpau-driver libva-utils vdpauinfo

rm -f /etc/profile.d/PackageKit.sh

# Fonts
dnf install -y dejavu-sans-fonts liberation-fonts mathjax-ams-fonts redhat-display-fonts google-roboto-fonts

# Fix xkb-lib
rm -rf /var/lib/xkb
ln -s /tmp/xkb /var/lib/xkb

# ---Installation of custom packages and environments---
dnf install -y cudnn
dnf install -y git

# Append commands for conda environment and jupyter notebooks
curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj bin/micromamba
export MAMBA_ROOT_PREFIX=$HOME/micromamba
eval "$(./bin/micromamba shell hook -s posix)"
# Linux/bash:
./bin/micromamba shell init -s bash -r ~/micromamba # this writes to your .bashrc file
# sourcing the bashrc file incorporates the changes into the running session.
source ~/.bashrc

micromamba activate
# exclusive conda-forge setup
micromamba config append channels conda-forge
micromamba config set channel_priority strict

# environment for micro-sam, sarcasm, trackastra
micromamba create -n cca python=3.11 -y
micromamba activate cca

# Install jupyter notebook packages and CUDA
micromamba install --quiet --yes \
notebook \
jupyterhub \
jupyterlab

# Here you can add your own python packages

micromamba install --quiet --yes \
jupyter \
napari \
pyqt \
pycocotools \
python-elf \
tensorboard \
tifffile \
tqdm \
torch_em \
micro_sam

# CUDA installation has to go through pip
export MAMBA_PREFIX=$HOME/micromamba/envs/cca
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MAMBA_PREFIX/lib/
python3.11 -m pip install torch torchvision torchaudio

# install other repositories
python3.11 -m pip install git+https://github.com/computational-cell-analytics/synapse-net
git clone https://github.com/computational-cell-analytics/synapse-net
cd synapse-net
python3.11 -m pip install -e .
cd ..
python3.11 -m pip install trackastra
python3.11 -m pip install sarc-asm

#---End of custom section---

# Override gnome-session-quit to kill the container and end the job
# (Unfortunately also removes the countdown.)
echo -e '#!/bin/bash\nkill $(pgrep -u $(id -u) gnome-session)' > /usr/bin/gnome-session-quit

# Audio passthrough (doesnt work yet)
#dnf install -y socat gstreamer1 gstreamer1-plugins-base gstreamer1-plugins-good gstreamer1-plugins-bad-free
#mkdir -p /etc/pulse/default.pa.d
#echo "load-module module-simple-protocol-tcp listen=127.0.0.1 format=s16le channels=2 rate=48000 record=true playback=false" > /etc/pulse/default.pa.d/simple-protocol.pa
#sed -i "/'websockify',/a \ '--token-plugin=UnixDomainSocketDirectory',\n f'--token-source={sockets_dir}'," ${install_dir}/jupyter_remote_desktop_proxy/setup_websockify.py
#sed -i '/+ websockify_args/d' ${install_dir}/jupyter_remote_desktop_proxy/setup_websockify.py
#sed -i "s/, f'cd/, f'\/usr\/local\/bin\/audio-proxy.sh -u {sockets_dir}\/audio \& cd/g" ${install_dir}/jupyter_remote_desktop_proxy/setup_websockify.py
#mv /usr/local/share/audio-plugin.js ${install_dir}/jupyter_remote_desktop_proxy/static/dist/audio-plugin.js
#sed -i '/<\/script>/a <script type="module" crossorigin="anonymous" src="{{base_url}}desktop/static/dist/audio-plugin.js"><\/script>' ${install_dir}/jupyter_remote_desktop_proxy/templates/index.html
#sed -i 's/desktop-websockify\/",/desktop-websockify\/?token=vnc-socket",/g' ${install_dir}/jupyter_remote_desktop_proxy/static/dist/viewer.js

echo "export MAMBA_ROOT_PREFIX=/root/micromamba" > $HOME/activate_micromamba.sh
echo "eval $(/usr/bin/micromamba shell hook -s posix)" >> $HOME/activate_micromamba.sh

chmod u+x $HOME/activate_micromamba.sh


%environment
# firefox does not work with user.max_net_namespaces=0
export MOZ_ASSUME_USER_NS=0
export JUPYTERHUB_DEFAULT_URL="/desktop"
export PATH="${PATH}:/usr/local/slurm/current/install/bin"
export XDG_DATA_DIRS="/usr/local/share:/usr/share:/var/lib/flatpak/exports/share"
export PS1=" \u@\h \W \$ "





Loading