From d03888282478360cf6f6b5370bc055d9f81357f3 Mon Sep 17 00:00:00 2001 From: Honney OC Date: Sun, 13 Sep 2026 20:18:39 +0000 Subject: [PATCH] fix: make install robust with torch fallbacks for gpu and py3.14 --- Makefile | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index 84fa83a..121c05c 100644 --- a/Makefile +++ b/Makefile @@ -29,49 +29,51 @@ help: install: @if [ ! -d $(VENV) ]; then echo "=> creating venv $(VENV)"; $(VENV_CREATE); else echo "=> venv exists $(VENV)"; fi @echo "=> detecting GPU..." - @HAS_ROCM=0; HAS_CUDA=0; \ + @HAS_ROCM=0; HAS_CUDA=0; PYVER=$$($(PY) -c "import sys;print(f'{sys.version_info.major}{sys.version_info.minor}')" 2>/dev/null || echo 314); \ if command -v rocm-smi >/dev/null 2>&1 && [ -c /dev/kfd ] && lspci 2>/dev/null | grep -qi amd; then HAS_ROCM=1; fi; \ if command -v nvidia-smi >/dev/null 2>&1; then HAS_CUDA=1; fi; \ + $(PIP_INSTALL) --upgrade pip; \ if [ $$HAS_ROCM -eq 1 ]; then \ - echo " ROCm detected (AMD) -> torch rocm6.2"; \ - $(PIP_INSTALL) --upgrade pip; \ - $(PIP_INSTALL) torch torchaudio --index-url https://download.pytorch.org/whl/rocm6.2; \ + echo " ROCm detected (AMD) -> torch rocm6.3 (fallback 6.2, cp314 needs 6.3+)"; \ + $(PIP_INSTALL) torch torchaudio --index-url https://download.pytorch.org/whl/rocm6.3 || \ + ( echo " rocm6.3 failed, trying rocm6.2"; $(PIP_INSTALL) torch torchaudio --index-url https://download.pytorch.org/whl/rocm6.2 ) || \ + ( echo " ROCm torch failed for py$$PYVER -> fallback cpu (numpy still works)"; $(PIP_INSTALL) torch torchaudio --index-url https://download.pytorch.org/whl/cpu || echo " torch install failed, continuing with numpy CPU fallback"); \ elif [ $$HAS_CUDA -eq 1 ]; then \ - echo " CUDA detected (NVIDIA) -> torch cu121"; \ - $(PIP_INSTALL) --upgrade pip; \ - $(PIP_INSTALL) torch torchaudio --index-url https://download.pytorch.org/whl/cu121; \ + echo " CUDA detected (NVIDIA) -> torch cu121 (fallback cu124)"; \ + $(PIP_INSTALL) torch torchaudio --index-url https://download.pytorch.org/whl/cu121 || \ + $(PIP_INSTALL) torch torchaudio --index-url https://download.pytorch.org/whl/cu124 || \ + ( echo " CUDA torch failed -> fallback cpu"; $(PIP_INSTALL) torch torchaudio --index-url https://download.pytorch.org/whl/cpu || true); \ else \ echo " No GPU -> torch cpu"; \ - $(PIP_INSTALL) --upgrade pip; \ - $(PIP_INSTALL) torch torchaudio --index-url https://download.pytorch.org/whl/cpu; \ + $(PIP_INSTALL) torch torchaudio --index-url https://download.pytorch.org/whl/cpu || echo " torch cpu install failed (py$$PYVER), continuing with numpy CPU fallback"; \ fi @echo "=> installing common deps..." - @$(PIP_INSTALL) soundfile scipy numpy pyqtgraph PyQt6 + @$(PIP_INSTALL) soundfile scipy numpy pyqtgraph PyQt6 || echo " common deps failed" @echo "=> optional sounddevice (audio playback, volume slider)..." @$(PIP_INSTALL) sounddevice || echo " sounddevice optional failed (PortAudio missing) -> playback disabled" - @$(PY) -c "import torch, sys; print(f'torch {torch.__version__} cuda_available={torch.cuda.is_available()}', end=''); print(f' device={torch.cuda.get_device_name(0)}' if torch.cuda.is_available() else ' (cpu)')" + @$(PY) -c "import torch, sys; print(f'torch {torch.__version__} cuda_available={torch.cuda.is_available()}', end=''); print(f' device={torch.cuda.get_device_name(0)}' if torch.cuda.is_available() else ' (cpu)')" 2>&1 || echo "torch not available, using numpy CPU fallback (still functional for 90s xcorr)" @echo "=> done. Activate: source $(VENV)/bin/activate" install-cpu: @if [ ! -d $(VENV) ]; then $(VENV_CREATE); fi $(PIP_INSTALL) --upgrade pip - $(PIP_INSTALL) torch torchaudio --index-url https://download.pytorch.org/whl/cpu + $(PIP_INSTALL) torch torchaudio --index-url https://download.pytorch.org/whl/cpu || echo "torch cpu failed, numpy fallback" $(PIP_INSTALL) soundfile scipy numpy pyqtgraph PyQt6 sounddevice || true - $(PY) -c "import torch; print(torch.__version__, torch.cuda.is_available())" + $(PY) -c "import torch; print(torch.__version__, torch.cuda.is_available())" 2>&1 || echo "torch not installed, numpy fallback" install-rocm: @if [ ! -d $(VENV) ]; then $(VENV_CREATE); fi $(PIP_INSTALL) --upgrade pip - $(PIP_INSTALL) torch torchaudio --index-url https://download.pytorch.org/whl/rocm6.2 + $(PIP_INSTALL) torch torchaudio --index-url https://download.pytorch.org/whl/rocm6.3 || $(PIP_INSTALL) torch torchaudio --index-url https://download.pytorch.org/whl/rocm6.2 || $(PIP_INSTALL) torch torchaudio --index-url https://download.pytorch.org/whl/cpu || echo "torch install failed, using numpy fallback" $(PIP_INSTALL) soundfile scipy numpy pyqtgraph PyQt6 sounddevice || true - $(PY) -c "import torch; print(torch.__version__, torch.cuda.is_available(), torch.cuda.get_device_name(0) if torch.cuda.is_available() else '')" + $(PY) -c "import torch; print(torch.__version__, torch.cuda.is_available(), torch.cuda.get_device_name(0) if torch.cuda.is_available() else '')" 2>&1 || echo "torch not installed, numpy fallback" install-cuda: @if [ ! -d $(VENV) ]; then $(VENV_CREATE); fi $(PIP_INSTALL) --upgrade pip - $(PIP_INSTALL) torch torchaudio --index-url https://download.pytorch.org/whl/cu121 + $(PIP_INSTALL) torch torchaudio --index-url https://download.pytorch.org/whl/cu121 || $(PIP_INSTALL) torch torchaudio --index-url https://download.pytorch.org/whl/cu124 || echo "torch cuda failed, fallback cpu" $(PIP_INSTALL) soundfile scipy numpy pyqtgraph PyQt6 sounddevice || true - $(PY) -c "import torch; print(torch.__version__, torch.cuda.is_available(), torch.cuda.get_device_name(0) if torch.cuda.is_available() else '')" + $(PY) -c "import torch; print(torch.__version__, torch.cuda.is_available(), torch.cuda.get_device_name(0) if torch.cuda.is_available() else '')" 2>&1 || echo "torch not installed" extract: @if [ -x $(PY) ]; then $(PY) extract.py; else python3 extract.py; fi