-
Notifications
You must be signed in to change notification settings - Fork 29
Mac compile script based on v0.6.2 #613
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
SuhasSrinivasan
wants to merge
12
commits into
nanoporetech:master
Choose a base branch
from
SuhasSrinivasan:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
505ee3f
Add script for Apple Silicon compilation
SuhasSrinivasan c968687
feat: enhance macOS compilation script with improved Python environme…
SuhasSrinivasan ef4909d
feat: add macOS installation guide for modkit
SuhasSrinivasan b955107
Add section for compiling on Apple Silicon
SuhasSrinivasan 58e1e0f
fix: update macOS prerequisites and enhance Python virtual environmen…
SuhasSrinivasan a49c5f8
fix: update macOS prerequisites to 12.3+ and enhance installation ins…
SuhasSrinivasan e14ed5d
feat: enhance macOS installation guide with RAYON_NUM_THREADS configu…
SuhasSrinivasan 1f93bbb
feat: add macOS compilation instructions for Apple Silicon with MPS a…
SuhasSrinivasan 6369a69
feat: enhance setup script with verbose option for detailed environme…
SuhasSrinivasan 83a3a26
feat: add version mismatch warning for Cargo.toml crate in checkout_v…
SuhasSrinivasan 10a0a1b
fix: clean up git working tree during repository update and improve v…
SuhasSrinivasan 8627ab2
fix: correct script execution flow and improve macOS version check ha…
SuhasSrinivasan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,146 @@ | ||
| # Modkit Installation for macOS | ||
|
|
||
| **Prerequisites:** Apple Silicon Mac, macOS 12.3+ (Monterey or later) | ||
|
|
||
| > **Why 12.3?** PyTorch MPS (Metal GPU backend) requires macOS 12.3+. The script exits early on older systems. | ||
|
|
||
| ## Quick Start | ||
|
|
||
| ```bash | ||
| bash mac_compile_modkit.sh ~/tools | ||
| ``` | ||
|
|
||
| Installs the latest modkit to `~/tools` using system Python. Takes 10–15 minutes. | ||
|
|
||
| --- | ||
|
|
||
| ## What Gets Installed | ||
|
|
||
| - Xcode Command Line Tools, Homebrew, Rust & Cargo | ||
| - Python virtual environment with PyTorch (GPU-enabled via Metal Performance Shaders) | ||
| - Compiled modkit binary at `~/tools/modkit/target/release/modkit` | ||
|
|
||
| --- | ||
|
|
||
| ## After Installation | ||
|
|
||
| The installer automatically adds the environment setup to `~/.zprofile`, so modkit is available in every new terminal session **silently** — no output is printed on shell startup. | ||
|
|
||
| To activate in the **current** session immediately after install: | ||
|
|
||
| ```bash | ||
| source ~/tools/setup_modkit_env.sh ~/tools | ||
| modkit --version | ||
|
SuhasSrinivasan marked this conversation as resolved.
|
||
| ``` | ||
|
|
||
| To see full environment details: | ||
|
|
||
| ```bash | ||
| source ~/tools/setup_modkit_env.sh ~/tools --verbose | ||
| ``` | ||
|
|
||
| `setup_modkit_env.sh` configures: | ||
| - `LIBTORCH`, `DYLD_LIBRARY_PATH`, `LD_LIBRARY_PATH` — required for the modkit binary to find libtorch | ||
| - `PATH` — so you can type `modkit` directly | ||
| - `RAYON_NUM_THREADS` — automatically set to the number of **Performance cores** on your Mac | ||
|
|
||
| ### RAYON_NUM_THREADS | ||
|
|
||
| Rayon is modkit's parallel processing library. On Apple Silicon, the script detects P-cores via: | ||
|
|
||
| ```bash | ||
| sysctl -n hw.perflevel0.logicalcpu # P-cores (used by default) | ||
| sysctl -n hw.perflevel1.logicalcpu # E-cores (for reference) | ||
| ``` | ||
|
|
||
| To override for a single run: | ||
|
|
||
| ```bash | ||
| RAYON_NUM_THREADS=8 modkit pileup input.bam output.bed | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Python Version Control | ||
|
|
||
| Three environment variables control Python selection: | ||
|
|
||
| | Variable | Values | Default | Purpose | | ||
| |----------|--------|---------|---------| | ||
| | `MODKIT_PYTHON_PROVIDER` | `auto`, `system`, `pyenv`, `uv` | `auto` | Which Python manager to use | | ||
| | `MODKIT_PYTHON_VERSION` | e.g. `3.11.9`, `3.12` | _(empty)_ | Request a specific Python version | | ||
| | `MODKIT_USE_UV` | `auto`, `0`, `1` | `auto` | Use `uv` for venv and pip operations | | ||
|
|
||
| ### Provider Notes | ||
|
|
||
| - **`auto`**: Uses `uv` or `pyenv` if `MODKIT_PYTHON_VERSION` is set and they are available; otherwise falls back to system `python3`. If a version is requested but neither tool is available, the script warns and prompts before falling back. | ||
| - **`system`**: Uses `python3` from `$PATH`. Version cannot be controlled. | ||
| - **`pyenv`**: Installs the requested version if needed. Does not change your global pyenv version. | ||
| - **`uv`**: Fastest option. Installs Python and manages the venv/pip. Auto-installed via Homebrew if needed. | ||
|
|
||
| **Venv reuse:** If a virtual environment already exists from a different Python configuration, the script detects the mismatch and prompts you to recreate it. | ||
|
|
||
| ### Examples | ||
|
|
||
| ```bash | ||
| # Default: system Python | ||
| bash mac_compile_modkit.sh ~/tools | ||
|
|
||
| # Specific version via pyenv | ||
| MODKIT_PYTHON_PROVIDER=pyenv MODKIT_PYTHON_VERSION=3.11.9 bash mac_compile_modkit.sh ~/tools | ||
|
|
||
| # Specific version via uv (fastest) | ||
| MODKIT_PYTHON_PROVIDER=uv MODKIT_PYTHON_VERSION=3.12 bash mac_compile_modkit.sh ~/tools | ||
|
|
||
| # Force standard pip (no uv) | ||
| MODKIT_USE_UV=0 bash mac_compile_modkit.sh ~/tools | ||
|
|
||
| # Specific modkit version | ||
| bash mac_compile_modkit.sh ~/tools v0.5.0 | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Common Issues & Fixes | ||
|
|
||
| ### "Could not resolve a usable Python executable" | ||
|
|
||
| ```bash | ||
| python3 --version # check if Python is available | ||
| brew install python@3.11 # install if missing | ||
| ``` | ||
|
|
||
| ### "PyTorch verification failed" | ||
|
|
||
| ```bash | ||
| source ~/tools/setup_modkit_env.sh ~/tools | ||
| ~/tools/venv_modkit/bin/python -m pip install --upgrade pip torch numpy | ||
| ``` | ||
|
|
||
| ### "Compilation failed" | ||
|
|
||
| > Always source the environment before rebuilding. Without it, `LIBTORCH` is unset and the build will fail again. | ||
|
|
||
| ```bash | ||
|
SuhasSrinivasan marked this conversation as resolved.
|
||
| source ~/tools/setup_modkit_env.sh ~/tools | ||
| cd ~/tools/modkit | ||
| cargo clean | ||
| cargo build --release --features accelerate,tch | ||
| ``` | ||
|
|
||
| ### "MPS available: false" | ||
|
|
||
| - Confirm Apple Silicon: `uname -m` should print `arm64` | ||
| - Confirm macOS 12.3+: `sw_vers -productVersion` | ||
| - CPU-only fallback is used automatically if MPS is unavailable | ||
|
|
||
| --- | ||
|
|
||
| ## Help & Details | ||
|
|
||
| ```bash | ||
| bash mac_compile_modkit.sh --help # all options | ||
| cat ~/tools/installation_info.txt # paths, versions, reproducible commands | ||
| modkit --help # modkit usage | ||
| ``` | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.