#!/usr/bin/env bash # One-shot setup for a fresh 8xB200 node. Idempotent: safe to re-run. # # bash /code/users/alexsu/project/fastkernels/setup_node.sh # # Everything this touches except /code is node-local and disappears when the # node is recycled, which is why this script exists. set -uo pipefail set -x LDAP=alexsu REPO="/code/users/${LDAP}/project/fastkernels" TOKEN_FILE="/code/users/${LDAP}/hf_token" # 1. Fail fast if the GPUs aren't visible. nvidia-smi -L || { echo "GPU not visible, aborting"; exit 1; } # 2. Convenience symlinks. ln -sfn /data-fast "${HOME}/data-fast" ln -sfn "/code/users/${LDAP}" "${HOME}/${LDAP}" ln -sfn "${REPO}" "${HOME}/fastkernels" # 3. HF token: the copy on FSX is the source of truth. mkdir -p /data-fast/huggingface cp "${TOKEN_FILE}" /data-fast/huggingface/token chmod 600 /data-fast/huggingface/token # 4. Shell env. if ! grep -q "FASTKERNELS_ENV_SETUP" "${HOME}/.bashrc"; then cat >> "${HOME}/.bashrc" <<'BASHRC_EOF' # --- FASTKERNELS_ENV_SETUP --- ulimit -c 0 export HF_HOME=/home/yak/data-fast/huggingface export HF_XET_HIGH_PERFORMANCE=1 export CPLUS_INCLUDE_PATH="/usr/local/cuda/include/cccl:${CPLUS_INCLUDE_PATH:-}" export C_INCLUDE_PATH="/usr/local/cuda/include/cccl:${C_INCLUDE_PATH:-}" export FASTKERNELS_RESULTS_DIR=/code/users/alexsu/vllm-validate export FK_VENV_ROOT=/data-fast/fk-venvs export UV_CACHE_DIR=/data-fast/uv-cache # Drop the K8s service vars; vLLM tries to parse anything named VLLM_*. unset $(env | cut -d= -f1 | grep -E '^(SOYOUNG_)?(VLLM|QWEN)_[A-Z0-9]+_.*(SERVICE|PORT)') 2>/dev/null # --- end --- BASHRC_EOF fi # 5. GitHub over 443; port 22 is blocked on this cluster. The github.com block # must come before the Host * wildcard or it never applies. mkdir -p "${HOME}/.ssh"; touch "${HOME}/.ssh/config" if ! grep -q '^Host github.com' "${HOME}/.ssh/config"; then { printf 'Host github.com\n HostName ssh.github.com\n Port 443\n ForwardAgent yes\n\n'; cat "${HOME}/.ssh/config"; } > "${HOME}/.ssh/config.new" mv "${HOME}/.ssh/config.new" "${HOME}/.ssh/config" chmod 600 "${HOME}/.ssh/config" fi ssh -T -o StrictHostKeyChecking=accept-new git@github.com || true # 6. Directories: results on FSX, venvs and uv cache on the node-local disk. mkdir -p "/code/users/${LDAP}/vllm-validate" /data-fast/fk-venvs /data-fast/uv-cache export UV_CACHE_DIR=/data-fast/uv-cache # 7. Repo (persists on FSX, so this is a no-op after the first node). if [ ! -d "${REPO}/.git" ]; then git clone --recursive ssh://git@github.com/Snowflake-AI-Research/fastkernels.git "${REPO}" fi cd "${REPO}" # 8. Dependencies. pyproject pins torch/vllm/transformers and the ABI-matched # flash-attn wheel, so `-e .` is all that's needed -- but deep-gemm builds # without build isolation, so torch has to already be importable. uv pip install torch==2.11.0 uv pip install -e . set +x echo "=== verify ===" python -c "import torch, vllm, flash_attn, fastkernels, transformers; \ print('torch', torch.__version__, '| cuda?', torch.cuda.is_available(), torch.cuda.device_count()); \ print('vllm', vllm.__version__, '| fa', flash_attn.__version__, '| hf', transformers.__version__)" echo "=== done. open a new shell (exec bash -l) before running anything. ==="