Skip to content

Instantly share code, notes, and snippets.

@verdimrc
verdimrc / docker-gpu.md
Last active April 15, 2025 10:08
GPU on docker and minikube
@verdimrc
verdimrc / cdk-BucketDeployment-checkov.ts
Last active April 11, 2023 04:18
Add Checkov metadata to CDK BucketDeployment
interface CheckovRule {
id: string,
comment: string,
}
function silence_checkov(construct: Construct, rules: CheckovRule[]) {
let metadata = (construct.node.defaultChild as cdk.CfnResource).cfnOptions.metadata;
metadata = { checkov: { skip: rules }, ...metadata };
(construct.node.defaultChild as cdk.CfnResource).cfnOptions.metadata = metadata
}
@verdimrc
verdimrc / trainer-logging.sh
Last active February 15, 2023 12:45
Huggingface
#!/bin/bash
#set -aex
echo "PWD = $(pwd)"
: "${SM_NUM_GPUS:=4}"
: "${MODEL_NAME:=gpt2}"
: "${OUTPUT_ROOT:=/mnt/scratch}"
: "${TRAINING_JOB_NAME:=haha}"
@verdimrc
verdimrc / slurm.md
Last active December 16, 2024 09:37
slurm.md

Slurm stuffs

1. Quickrun

# Rapid test
srun --nodes 2 --ntasks-per-node 1 /usr/bin/hostname

# Move job to another partition
scontrol update job <jobid> Partition=<partition_name>
@verdimrc
verdimrc / diagnose-disk-usage.md
Last active April 25, 2024 06:29
ec2-storage
  • Was enroot command on the controller node?
  • What is enroot.conf?
  • Instance type of controller node
  • The output of df -h
  • The output of mount command
  • The output of sudo du -shc /tmp/
  • The output of sudo du -shc /var/lib/*
  • The output of docker images
  • Run docker system prune to clean-up unused Docker caches
@verdimrc
verdimrc / sphinx.sh
Created August 3, 2022 04:26
sphinx.sh
# List content of object.inv as plain text to stdout.
python -m sphinx.ext.intersphinx https://docs.python.org/3/objects.inv
# Alternative
pip install sphobjinv
sphobjinv --help
@verdimrc
verdimrc / watch-accel.sh
Last active December 19, 2024 21:49
watch-accel.sh
################################################################################
# NVIDIA
################################################################################
nvidia-smi -l
nvidia-smi -l 1
nvidia-smi -l 1 --format=csv --query-gpu=gpu_name,index,utilization.memory,memory.total,memory.reserved,memory.used,memory.free
nvidia-smi -l 1 --format=csv --query-gpu=gpu_name,index,utilization.memory,memory.total,memory.reserved,memory.used,memory.free 2>&1 | tee /tmp/haha.txt
declare -a ARGS=(
-l 1
@verdimrc
verdimrc / gitlab-runner.sh
Last active May 11, 2022 10:23
gitlab-runner.sh
# Miscellaneous references:
# - https://docs.gitlab.com/ee/ci/unit_test_reports.html#python-example
# - https://docs.gitlab.com/ee/user/project/merge_requests/code_quality.html
# - https://stackoverflow.com/a/36358790
# NOTES:
# - apparently, gitlab is deprecating gitlab-runner exec
# - alt OSS: https://github.com/firecow/gitlab-ci-local
################################################################################
@verdimrc
verdimrc / python-wheel.sh
Last active May 5, 2022 13:01
python wheel
# No isolation: don't build on a venv (because requirements*txt may be missing).
pip install build setupext-janitor
python3 -m build --wheel --no-isolation
# Optional: remove build artifacts ONLY.
VIRTUAL_ENV='' python setup.py clean --all
# Optional: remove build artifacts PLUS the currently active virtual env.
python setup.py clean --all
@verdimrc
verdimrc / gh-example.py
Created February 11, 2022 04:13
gh-example.py
import rich.pretty
rich.pretty.install()
import os
from github3 import login
gh = login(username="username", token=os.environ["token"])
repo = gh.repository("username", "reponame")