This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Tutorial: Running DeepVariant natively on macOS Apple Silicon (M1/M2/M3/M4) with Metal GPU acceleration

Hey Everyone. Just sharing this here in case anyone is doing bioinformatic work on an Apple Silicon Mac and wants to run DeepVariant locally.

Google's official DeepVariant Docker image (x86_64) crashes on Apple Silicon because TensorFlow requires AVX instructions that Rosetta 2 can't emulate. Running a native ARM64 Linux container avoids this, but loses GPU acceleration entirely.

I've created a native macOS ARM64 build of DeepVariant v1.9.0 that runs directly on Apple Silicon with Metal GPU acceleration support (4.25x speedup for call_variants when I run it on M1 Max). As far as I'm aware, until now, it was basically impossible to run DeepVariant natively on Apple Silicon at all.

It easily installs with Homebrew:

brew tap antomicblitz/deepvariant
brew install deepvariant
deepvariant-download-model WGS
deepvariant-quicktest

Then run (same flags as google's official version):

run_deepvariant \
  --model_type=WGS \
  --ref=reference.fasta \
  --reads=input.bam \
  --output_vcf=output.vcf.gz \
  --num_shards=$(sysctl -n hw.ncpu)

All of their model types are supported: WGS, WES, PACBIO, ONT_R104, HYBRID_PACBIO_ILLUMINA, MASSEQ.

Conda/venv install is also available. I tested on my M1 Max and a developer from Google also confirmed it works on their M4. Accuracy matches published benchmarks.

I appreciate if anyone in the community could give it a try and let me know if you run into any issues or if you have any feedback. I vibe coded the whole thing.

GitHub Repo

apple-silicon metal-gpu macos variant-calling deepvariant

This fork patches the Bazel build system, C++ source, and third-party dependencies to compile and run natively on macOS ARM64 with Apple Clang.

How did you get around the AVX instructions requirement?

AVX is only needed because the official build ships pre-compiled x86_64 binaries. I recompiled DeepVariant (and its TensorFlow + CLIF dependencies) from source directly on ARM64, producing native Apple Silicon binaries. ARM NEON handles the SIMD operations instead of AVX.

Can you not just rebuild the image with their Dockerfile using the ARM flag during docker build?

Technically, I guess you could, but you'd be CPU-only (with emulation) and with no Metal GPU acceleration. I benchmarked running without Metal and it's more than 4x slower, which makes it impractical, especially when you can install this with just a few lines with Homebrew. Anyway I should probably correct my statement a bit so it's not misleading. You could technically run it before, but without GPU acceleration.

0 answers

No answers yet.

Log in to answer this question.