From 57238d6f6e4f2f26b3b27727634d9d3db7be24ac Mon Sep 17 00:00:00 2001 From: Thomas Hallock Date: Tue, 6 Jan 2026 07:09:08 -0600 Subject: [PATCH] fix(vision): use ARM Python venv for Metal GPU detection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The hardware detection was using system python3 which was x86_64 (Rosetta) instead of native ARM. This prevented TensorFlow from detecting the Metal GPU on Apple Silicon. Now uses a Python 3.11 venv with tensorflow-macos and tensorflow-metal for proper M4 Max GPU detection. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- apps/web/.gitignore | 1 + .../web/src/app/api/vision-training/hardware/route.ts | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/apps/web/.gitignore b/apps/web/.gitignore index a47682a3..1a49a7f0 100644 --- a/apps/web/.gitignore +++ b/apps/web/.gitignore @@ -63,3 +63,4 @@ data/uploads/ # ML training data training-data/ +scripts/train-column-classifier/.venv/ diff --git a/apps/web/src/app/api/vision-training/hardware/route.ts b/apps/web/src/app/api/vision-training/hardware/route.ts index 1ea852d6..e674449b 100644 --- a/apps/web/src/app/api/vision-training/hardware/route.ts +++ b/apps/web/src/app/api/vision-training/hardware/route.ts @@ -45,9 +45,16 @@ export async function GET(): Promise { let stderr = '' let hasError = false - const childProcess = spawn('python3', [scriptPath], { + // Use the venv Python with tensorflow-metal for proper GPU detection + const venvPython = path.join(cwd, 'scripts/train-column-classifier/.venv/bin/python') + + const childProcess = spawn(venvPython, [scriptPath], { cwd, - env: { ...process.env, PYTHONUNBUFFERED: '1' }, + env: { + ...process.env, + PYTHONUNBUFFERED: '1', + PYTHONWARNINGS: 'ignore::FutureWarning', // Suppress keras warning + }, }) childProcess.stdout?.on('data', (data: Buffer) => {