Brainrot_Muxa/docker-entrypoint.sh

119 lines
4.1 KiB
Bash
Executable file
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
set -e
# ==============================================================================
# FlyGuard: Bionic Obstacle Detection Core (LCT-2026, Case 05)
# Hesai Pandar128 LiDAR (128 beams, 10 Hz / 100ms)
# Universal Entrypoint: NVIDIA GPU Acceleration (CUDA 12.x) with CPU Fallback
# ==============================================================================
print_banner() {
echo "============================================================================"
echo " FlyGuard · Блиц-обнаружение препятствий в тоннеле метро (Кейс 05, ЛЦТ-2026)"
echo " Hesai Pandar128 (128 лучей, 10 Гц / 100 мс) · NVIDIA CUDA 12 / CPU Fallback"
echo "============================================================================"
}
print_device_info() {
python3 -c "
try:
import flyguard.device as dev
info = dev.get_device_info()
if info['cuda_available']:
print(f'==> [HARDWARE] NVIDIA GPU: {info[\"device_name\"]} (Compute {info[\"compute_capability\"]}, {info[\"total_memory_gb\"]} GB VRAM)')
print(f'==> [ACCELERATION] CUDA 12: АКТИВНО (PyTorch {info[\"torch_version\"]})')
else:
print('==> [HARDWARE] CPU Mode: CUDA недоступна или не передана в контейнер.')
print('==> [FALLBACK] Активирован автоматический Graceful Fallback на CPU.')
except Exception as e:
print(f'==> Проверка окружения: {e}')
"
}
CMD="${1:-default}"
case "$CMD" in
default|run)
print_banner
print_device_info
DATA_DIR="${FLYGUARD_DATA:-/data}"
FOUND_BAG=$(find "$DATA_DIR" -name '*.db3' 2>/dev/null | head -n 1 || true)
if [ -d "$DATA_DIR" ] && [ -n "$FOUND_BAG" ]; then
echo "==> Обнаружены бэги лидара в $DATA_DIR. Запуск конвейера FlyGuard по всем записям..."
exec python3 tools/run_pipeline.py --all \
--memory artifacts/mushroom_body.npz \
--readout artifacts/mbon_readout.npz \
--device auto \
--verbose
else
echo "==> В $DATA_DIR не найдены файлы .db3 (датасет не смонтирован через -v /путь/к/data:/data)."
echo "==> Выполняется системный прогон верификационных тестов и роутинга..."
exec python3 tests/run_tests.py
fi
;;
pipeline|run-pipeline)
shift
print_banner
print_device_info
exec python3 tools/run_pipeline.py \
--memory artifacts/mushroom_body.npz \
--readout artifacts/mbon_readout.npz \
--device auto "$@"
;;
benchmark|make-benchmark)
shift
print_banner
print_device_info
exec python3 tools/make_benchmark.py \
--memory artifacts/mushroom_body.npz \
--mbon-dir artifacts/mbon_folds \
--device auto "$@"
;;
evaluate)
shift
print_banner
print_device_info
exec python3 tools/evaluate.py \
--mbon-dir artifacts/mbon_folds \
--device auto "$@"
;;
train-mbon)
shift
print_banner
print_device_info
exec python3 tools/train_mbon.py \
--device auto "$@"
;;
train-track)
shift
print_banner
print_device_info
exec python3 tools/train_track.py \
--device auto "$@"
;;
test|tests|run-tests)
shift
print_banner
print_device_info
exec python3 tests/run_tests.py "$@"
;;
pytest)
shift
exec pytest tests "$@"
;;
info|device|gpu|gpu-info)
print_banner
python3 -c "
import json
import flyguard.device as dev
print(json.dumps(dev.get_device_info(), indent=2, ensure_ascii=False))
"
;;
bash|sh)
shift
exec /bin/bash "$@"
;;
*)
exec "$@"
;;
esac