File size: 1,025 Bytes
6d5c79f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env bash
set -euo pipefail

PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"

python3.11 -m venv "${PROJECT_ROOT}/.venv"
source "${PROJECT_ROOT}/.venv/bin/activate"

python -m pip install --upgrade pip wheel setuptools
python -m pip install -r "${PROJECT_ROOT}/requirements.txt"

export PYTHONPATH="${PROJECT_ROOT}:${PYTHONPATH:-}"
export TOKENIZERS_PARALLELISM=false
export CUDA_DEVICE_MAX_CONNECTIONS=1
export NCCL_IB_DISABLE=0
export NCCL_SOCKET_IFNAME="ib0,eth0"

python - <<'PY'
import json
import subprocess
import torch

info = {
    "cuda_available": torch.cuda.is_available(),
    "gpu_count": torch.cuda.device_count(),
}
if torch.cuda.is_available():
    info["devices"] = [torch.cuda.get_device_name(i) for i in range(torch.cuda.device_count())]
print(json.dumps(info, indent=2))
PY

if command -v ibstat >/dev/null 2>&1; then
  ibstat || true
fi

if command -v nvidia-smi >/dev/null 2>&1; then
  nvidia-smi topo -m || true
fi

echo "Environment setup complete at ${PROJECT_ROOT}/.venv"