Skip to content

Instantly share code, notes, and snippets.

@nik-ko
nik-ko / gpu2container.sh
Created February 12, 2026 08:59
Show GPU compute processes and the users/commands behind them, including associated Docker containers
#!/usr/bin/env bash
# This script enumerates current GPUs and Docker containers, matches running compute processes to the GPU they run on, and prints a tabular summary including the process ID, owner, memory usage, and the container context (container ID, name, and image) when available. Enables diagnosing GPU-accelerated workloads and their container associations. Copy to /usr/local/bin/gpu2container and make it executable.
set -euo pipefail
CMDLEN="${GPU2CONTAINER_CMDLEN:-140}" # override via env var if desired
command -v nvidia-smi >/dev/null || { echo "ERROR: nvidia-smi not found"; exit 1
; }
command -v docker >/dev/null || { echo "ERROR: docker not found"; exit 1; }
command -v column >/dev/null || { echo "ERROR: column not found (util-linux)"; e
@nik-ko
nik-ko / fix_cites_title_in_bibtex.py
Created February 20, 2024 07:52
Replace lowercase in title, journal and booktitle in BibTeX entries with titlecase e.g., 'The greatest title of the all time' to 'The Greatest Title of All Time'. Extends https://www.dlgreenwald.com/miscellanea/capitalizing-titles-in-bibtex to process all *.bib files in a directory recursively.
"""
Replace lowercase in title, journal and booktitle in BibTeX entries with titlecase
e.g., 'The greatest title of the all time' to 'The Greatest Title of All Time'.
Extends https://www.dlgreenwald.com/miscellanea/capitalizing-titles-in-bibtex
to process all *.bib files in a directory recursively.
"""
import shutil
import regex as re