File size: 2,826 Bytes
5b86813 | 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 | #!/usr/bin/env fish
# Quick Setup Script for Arch Linux + RTX 2050
# Road Anomaly Detection Training
echo "π Setting up Road Anomaly Detection training environment..."
echo " Target: NVIDIA RTX 2050 (4GB VRAM)"
echo ""
# =============================================================================
# RTX 2050 CUDA Environment Variables (4GB VRAM optimization)
# =============================================================================
set -gx CUDA_VISIBLE_DEVICES 0
set -gx PYTORCH_CUDA_ALLOC_CONF "max_split_size_mb:512"
set -gx TF_FORCE_GPU_ALLOW_GROWTH "true"
# Ensure `uv` (env manager) is installed and create/activate a virtual environment
if not type -q uv
echo "Installing uv (preferred via pipx)..."
if type -q pipx
pipx install uv || pip install --user uv
else if type -q pip
pip install --user uv
else
echo "Error: neither pipx nor pip found. Install pip or pipx and retry."
exit 1
end
end
# Create virtualenv with uv (creates .venv by default)
if not test -d .venv
uv venv
else
echo ".venv already exists; skipping creation."
end
# Activate the fish activation script if available
if test -f .venv/bin/activate.fish
source .venv/bin/activate.fish
else if test -f .venv/bin/activate
source .venv/bin/activate
end
# Install PyTorch with CUDA into the uv-managed environment
uv pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
# Install project dependencies into the uv-managed environment
uv pip install ultralytics opencv-python matplotlib albumentations numpy pandas seaborn pillow tqdm PyYAML tensorboard onnx onnxruntime
# Install TFLite export dependencies
uv pip install tensorflow
# Verify setup
echo ""
echo "Verifying installation..."
python -c "import torch; print('β PyTorch:', torch.__version__); print('β CUDA Available:', torch.cuda.is_available()); print('β GPU:', torch.cuda.get_device_name(0) if torch.cuda.is_available() else 'None')"
python -c "from ultralytics import YOLO; print('β Ultralytics YOLOv8 ready')"
echo ""
echo "βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ"
echo "β Setup complete! Ready to train."
echo "βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ"
echo ""
echo "Next steps:"
echo " 1. Verify dataset: python verify_dataset.py"
echo " 2. Train model: python train_road_anomaly_model.py"
echo " 3. Run inference: python inference.py --model <model.pt> --source <image/video>"
echo " 4. Package for RPi: python package_for_rpi.py"
echo ""
echo "Monitor GPU during training:"
echo " watch -n 1 nvidia-smi"
echo ""
|