File size: 2,198 Bytes
26bde8f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b71073c
 
 
8965662
 
b71073c
8965662
 
 
 
 
b71073c
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
#!/usr/bin/env bash
set -euo pipefail

echo "postBuild: starting detectron2 setup"
python -V || true
pip --version || true

# Ensure torch is present and print environment info
python - <<'PY' || true
import torch, platform, sys
print("Torch:", torch.__version__)
print("CUDA available:", torch.cuda.is_available())
print("torch.version.cuda:", getattr(torch.version, "cuda", None))
print("Python:", sys.version.split()[0])
print("Platform:", platform.platform())
PY

# Determine expected wheel index (CPU or CUDA) based on installed torch
PYTORCH_MM="$(python - <<'PY'
import torch
v = torch.__version__.split('+')[0].split('.')
print(f"{v[0]}.{v[1]}")
PY
)"
CUDA_TAG="$(python - <<'PY'
import torch
cv = getattr(torch.version, "cuda", None)
print(("cu"+cv.replace(".","")) if cv else "cpu")
PY
)"

WHEEL_URL="https://dl.fbaipublicfiles.com/detectron2/wheels/${CUDA_TAG}/torch${PYTORCH_MM}/index.html"
echo "Attempting detectron2 wheel from: ${WHEEL_URL}"

if pip install --no-cache-dir "detectron2" -f "${WHEEL_URL}"; then
  echo "detectron2 installed from prebuilt wheel"
else
  echo "Prebuilt wheel not available. Building detectron2 from source (CPU-only) ..."
  export FORCE_CUDA=0
  pip install --no-cache-dir --no-build-isolation "git+https://github.com/facebookresearch/detectron2.git@fd27788985af0f4ca800bca563acdb700bb890e2"
fi

# Verify installation
python - <<'PY'
import importlib
spec = importlib.util.find_spec("detectron2")
if spec is None:
    raise SystemExit("detectron2 not found after installation")
import detectron2
print("detectron2 installed. Version:", getattr(detectron2, "__version__", "unknown"))
PY

echo "postBuild: detectron2 setup completed"
#!/bin/sh
set -e

echo "[postBuild] Prepare build tools..."
python -m pip install -U pip setuptools wheel ninja

echo "[postBuild] Installing vendored detectron2 from MaskClustering/third_party/detectron2 ..."
# Torch уже установлен из requirements.txt к моменту postBuild.
# Отключаем build isolation, чтобы сборка видела установленный torch.
export MAX_JOBS=${MAX_JOBS:-1}
python -m pip install --no-build-isolation -e MaskClustering/third_party/detectron2