Skip to content

MEGAHIT fails if --num-cpu-threads > 1 when running under macOS #385

@fethalen

Description

@fethalen

MEGAHIT v1.2.9 fails on macOS (both Intel and Apple Silicon) when using --num-cpu-threads > 1. Using one thread works fine. Running the same command via Docker on Linux works correctly, confirming that the issue is specific to macOS.

To reproduce:

  1. Install MEGAHIT via Conda:
CONDA_SUBDIR=osx-arm64 conda create -n megahit-arm64 -c bioconda -c conda-forge megahit
conda activate megahit-arm64
  1. Download example dataset (412MB):
curl -O https://s3.amazonaws.com/public.ged.msu.edu/ecoli_ref-5m.fastq.gz
  1. Run MEGAHIT on FASTQ files:
megahit -r ecoli_ref-5m.fastq.gz \
  --num-cpu-threads 2 \
  -o results

MEGAHIT output:

2025-09-26 10:17:52 - MEGAHIT v1.2.9
2025-09-26 10:17:52 - Using megahit_core without POPCNT and BMI2 support, because the features not detected by CPUID 
2025-09-26 10:17:52 - Convert reads to binary library
2025-09-26 10:17:54 - b'INFO  sequence/io/sequence_lib.cpp  :   77 - Lib 0 (/Users/fsandberg/projects/megahit_silicon_macs/ecoli_ref-5m.fastq.gz): se, 5000000 reads, 100 max length'
2025-09-26 10:17:54 - b'INFO  utils/utils.h                 :  152 - Real: 2.6342\tuser: 1.2629\tsys: 0.3015\tmaxrss: 266534912'
2025-09-26 10:17:54 - k-max reset to: 119 
2025-09-26 10:17:54 - Start assembly. Number of CPU threads 2 
2025-09-26 10:17:54 - k list: 21,29,39,59,79,99,119 
2025-09-26 10:17:54 - Memory used: 23192823398
2025-09-26 10:17:54 - Extract solid (k+1)-mers for k = 21 
2025-09-26 10:18:23 - Build graph for k = 21 
2025-09-26 10:18:25 - Assemble contigs from SdBG for k = 21
2025-09-26 10:18:32 - Local assembly for k = 21
2025-09-26 10:18:37 - Extract iterative edges from k = 21 to 29 
2025-09-26 10:18:42 - Build graph for k = 29 
2025-09-26 10:18:42 - Assemble contigs from SdBG for k = 29
2025-09-26 10:18:45 - Local assembly for k = 29
2025-09-26 10:18:50 - Extract iterative edges from k = 29 to 39 
2025-09-26 10:18:54 - Build graph for k = 39 
2025-09-26 10:18:57 - Error occurs, please refer to /Users/fsandberg/projects/megahit_silicon_macs/results/log for detail
2025-09-26 10:18:57 - Command: /Users/fsandberg/miniconda3/envs/megahit-arm64/bin/megahit_core_popcnt seq2sdbg --host_mem 23192823398 --mem_flag 1 --output_prefix /Users/fsandberg/projects/megahit_silicon_macs/results/tmp/k39/39 --num_cpu_threads 2 -k 39 --kmer_from 29 --input_prefix /Users/fsandberg/projects/megahit_silicon_macs/results/tmp/k39/39 --addi_contig /Users/fsandberg/projects/megahit_silicon_macs/results/intermediate_contigs/k29.addi.fa --local_contig /Users/fsandberg/projects/megahit_silicon_macs/results/intermediate_contigs/k29.local.fa --contig /Users/fsandberg/projects/megahit_silicon_macs/results/intermediate_contigs/k29.contigs.fa --bubble /Users/fsandberg/projects/megahit_silicon_macs/results/intermediate_contigs/k29.bubble_seq.fa; Exit code -11

Expected behavior:

MEGAHIT should run successfully using multiple threads, just like it does in Docker on Linux.

Environment:

Machine: Apple MacBook Pro M4 Pro, 12-core CPU (8 performance + 4 efficiency), 24 GB memory
OS: macOS Sequoia 15.6.1
MEGAHIT version: 1.2.9

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions