fix(vision): use ARM Python venv for Metal GPU detection

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 <noreply@anthropic.com>
This commit is contained in:
Thomas Hallock 2026-01-06 07:09:08 -06:00
parent efa35de92d
commit 57238d6f6e
2 changed files with 10 additions and 2 deletions

1
apps/web/.gitignore vendored
View File

@ -63,3 +63,4 @@ data/uploads/
# ML training data
training-data/
scripts/train-column-classifier/.venv/

View File

@ -45,9 +45,16 @@ export async function GET(): Promise<Response> {
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) => {