File size: 2,892 Bytes
bb23b91
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env bash
# Portable RUN_DIR / PY / CUDNN_LIB for slimgpu vs Berkeley (gandalf/feanor).
#
# Override any of these before sourcing:
#   SUDOKU_RUN_DIR, SUDOKU_PY, SUDOKU_CUDNN_LIB
#
# Usage (from launch_*.sh):
#   source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/env_paths.sh"

_SLIM_ROOT="/egr/research-slim/ghoshavr/llm-reasoning-logic-puzzles"
_SLIM_RUN="${_SLIM_ROOT}/sudoku-code/multicandidate_run"
_SLIM_PY="/egr/research-slim/ghoshavr/conda-envs/logicpuzzles/bin/python"
_SLIM_CUDNN="/egr/research-slim/ghoshavr/conda-envs/logicpuzzles/lib/python3.9/site-packages/nvidia/cudnn/lib"

# Berkeley: prefer scratch (home often quota-limited), then $HOME (may be a symlink).
_BERK_RUN_SCRATCH="/scratch/users/gatmiry/llm-reasoning-logic-puzzles/sudoku-code/multicandidate_run"
_BERK_RUN="${HOME}/llm-reasoning-logic-puzzles/sudoku-code/multicandidate_run"

# Prefer explicit overrides, then slimgpu tree if present, else Berkeley home.
if [ -n "${SUDOKU_RUN_DIR:-}" ]; then
  RUN_DIR="${SUDOKU_RUN_DIR}"
elif [ -d "${_SLIM_RUN}" ]; then
  RUN_DIR="${_SLIM_RUN}"
elif [ -d "${_BERK_RUN_SCRATCH}" ]; then
  RUN_DIR="${_BERK_RUN_SCRATCH}"
else
  RUN_DIR="${_BERK_RUN}"
fi

if [ -n "${SUDOKU_PY:-}" ]; then
  PY="${SUDOKU_PY}"
elif [ -x "${_SLIM_PY}" ]; then
  PY="${_SLIM_PY}"
else
  # Common Berkeley conda layouts; first existing wins.
  for _cand in \
      "${HOME}/miniconda3/envs/logic_puzzles/bin/python" \
      "${HOME}/miniconda3/envs/logicpuzzles/bin/python" \
      "${HOME}/anaconda3/envs/logic_puzzles/bin/python" \
      "${HOME}/anaconda3/envs/logicpuzzles/bin/python" \
      "${HOME}/.conda/envs/logic_puzzles/bin/python" \
      "${HOME}/.conda/envs/logicpuzzles/bin/python" \
      "/scratch/users/gatmiry/conda/envs/logic_puzzles/bin/python" \
      "/scratch/users/gatmiry/conda/envs/logicpuzzles/bin/python"; do
    if [ -x "${_cand}" ]; then
      PY="${_cand}"
      break
    fi
  done
  if [ -z "${PY:-}" ]; then
    if command -v python >/dev/null 2>&1; then
      PY="$(command -v python)"
    else
      echo "ERROR: no Python found. Create env: conda env create -f ~/llm-reasoning-logic-puzzles/environment.yml -n logic_puzzles" >&2
      echo "  then: export SUDOKU_PY=\$HOME/miniconda3/envs/logic_puzzles/bin/python" >&2
      return 1 2>/dev/null || exit 1
    fi
  fi
fi

if [ -n "${SUDOKU_CUDNN_LIB:-}" ]; then
  CUDNN_LIB="${SUDOKU_CUDNN_LIB}"
elif [ -d "${_SLIM_CUDNN}" ]; then
  CUDNN_LIB="${_SLIM_CUDNN}"
else
  # Derive from PY site-packages if present; else leave empty (cluster CUDA often enough).
  _py_root="$(cd "$(dirname "${PY}")/.." && pwd)"
  _cudnn_guess="${_py_root}/lib/python3.9/site-packages/nvidia/cudnn/lib"
  if [ -d "${_cudnn_guess}" ]; then
    CUDNN_LIB="${_cudnn_guess}"
  else
    CUDNN_LIB=""
  fi
fi

export RUN_DIR PY CUDNN_LIB
unset _SLIM_ROOT _SLIM_RUN _SLIM_PY _SLIM_CUDNN _BERK_RUN _cand _py_root _cudnn_guess