This repository contains isolated AI/ML environments managed with Pixi, a modern package manager for scientific computing and data science.
Pixi is a fast, cross-platform package manager that combines the best of conda and pip:
- vs Conda: Pixi is faster, uses a modern lock file format for reproducibility, and provides a better developer experience with tasks and workspaces
- vs Pip: Pixi handles both Python and non-Python dependencies (like CUDA, system libraries), manages Python versions automatically, and creates isolated environments per project
- Best of both: Install packages from conda-forge AND PyPI in the same environment, with automatic dependency resolution
iwr -useb https://pixi.sh/install.ps1 | iex
curl -fsSL https://pixi.sh/install.sh | sh
Or with wget:
wget -qO- https://pixi.sh/install.sh | sh
After installation, restart your terminal to use pixi.
For more installation options, visit: https://pixi.sh/dev/installation/
Each folder contains its own isolated pixi environment with specific AI/ML tools:
CAREamics/ β’ Documentation
Deep learning-based image restoration and denoising toolkit. Uses CUDA 12.8 with PyTorch.
- Purpose: Image denoising and restoration for microscopy images
- Key packages: careamics, torch, torchvision, bioio
- Features: Multiple environments (default, bioio, imagej)
cellpose/ β’ Documentation
Generalist algorithm for cell and nucleus segmentation with GPU acceleration.
- Purpose: Cell segmentation using deep learning
- Key packages: cellpose 4 with GUI, PyTorch
- CUDA: 12.8
micro_sam/ β’ Documentation
Segment Anything Model (SAM) adapted for microscopy images.
- Purpose: Interactive and automatic segmentation for microscopy using napari
- Key packages: micro_sam, pytorch, napari-omero, trackastra
- CUDA: 12.8
biapy/ β’ Documentation
BiaPy - Library for training bioimage analysis AI models.
- Purpose: Training deep learning models for bioimage analysis workflows
- Key packages: biapy, mlflow (for experiment tracking), scikit-learn
- Python: 3.12
stardist/ β’ GitHub
Star-convex object detection in microscopy images, especially for segmentation of cell nuclei.
- Purpose: Object detection and instance segmentation
- Key packages: stardist, napari, tensorflow 2.10
- CUDA: 11.8 (older version for TensorFlow compatibility)
trackastra/ β’ GitHub
Deep learning-based cell tracking for microscopy time-lapse data.
- Purpose: Cell tracking across time series
- Key packages: trackastra, PyTorch
- CUDA: 12.8
Navigate to any folder and activate its environment:
cd cellpose
#optionally run first
pixi install
pixi shell
This starts an interactive shell with all dependencies available. To exit, type exit
.
Each environment can run specific applications using pixi tasks:
# In the cellpose folder
pixi run cellpose # Launch Cellpose GUI
# In the stardist folder
pixi run napari # Launch Napari viewer
# Run Python in any environment
pixi run python # Starts Python with all packages available
Most environments include Jupyter support for interactive data analysis and experimentation:
# Navigate to any folder with Jupyter support
cd CAREamics
# or: cd cellpose, micro_sam, biapy
# Launch Jupyter Lab with the correct Python environment
pixi run jupyter lab
Environments with Jupyter:
- β CAREamics
- β cellpose
- β micro_sam
- β biapy
- β stardist (via jupyter-client)
- β trackastra
Benefits:
- π Notebooks automatically use the correct Python environment
- π¦ All packages from
pixi.toml
are available in notebooks - π¬ Perfect for experimentation, visualization, and interactive analysis
- π― No need to manually select kernels or worry about environment mismatches
# Navigate to the project folder
cd micro_sam
# Run Python scripts directly
pixi run python your_script.py
# Or activate the shell first
pixi shell
python your_script.py
Most environments include a test-cuda
task to verify GPU setup:
# In any folder with CUDA support
pixi run test-cuda
This command checks:
- β CUDA availability
- π’ CUDA version
- π₯οΈ GPU device count and name
cd stardist
pixi run test-stardist
This runs stardist_test.py
to verify the installation and GPU configuration.
Tasks are custom commands defined in pixi.toml
files. They make common operations easy:
test-cuda
: Verifies PyTorch CUDA setup (available in: cellpose, micro_sam, trackastra, CAREamics, biapy)test-stardist
: Tests StarDist installation and runs example code
cd <project-folder>
pixi task list
pixi run <task-name>
Tasks can be simple commands or complex scripts. Check each folder's pixi.toml
to see available tasks.
Each folder in this repository has its own isolated environment:
- π Folder-based: Each project folder contains a
pixi.toml
configuration file - π Isolated Python: Python and all dependencies are installed in a
.pixi
folder within each project - π No conflicts: Different projects can use different Python versions and package versions
- π« No global installation: Environments don't interfere with your system Python or other projects
Example structure:
cellpose/
βββ pixi.toml # Configuration file
βββ pixi.lock # Lock file for reproducibility
βββ .pixi/ # Environment folder (created automatically)
βββ envs/
βββ default/ # Python and packages installed here
Want to create a new AI tool environment? Here's how:
# 1. Create a new folder and initialize pixi
mkdir my_project
cd my_project
pixi init
# 2. Add Python (specify your desired version)
pixi add python=3.12
# or: pixi add python=3.11, python=3.10, etc.
# 3. Add conda packages (from conda-forge)
pixi add numpy pandas matplotlib
pixi add pytorch torchvision
# 4. Add PyPI packages (from PyPI)
pixi add --pypi scikit-learn
pixi add --pypi transformers
pixi add --pypi napari-omero
# 5. Start using your environment
pixi shell # Activate environment
pixi run python # Run Python directly
pixi run jupyter lab # Run Jupyter (if added)
When to use pixi add
(conda):
- β System libraries and compiled packages (CUDA, OpenCV, etc.)
- β Python itself and major scientific packages (numpy, scipy, pytorch)
- β Generally faster and more reliable dependency resolution
When to use pixi add --pypi
(PyPI):
- β Python-only packages not available in conda-forge
- β Latest versions of packages that update frequently
- β Packages specifically requiring pip installation
Important: Pixi resolves dependencies in a specific order:
- First: Conda packages from conda-forge
- Then: PyPI packages with pip
This means conda packages take priority. If you need a specific version from PyPI, ensure it's not being overridden by a conda package.
Each environment has a pixi.lock
file that ensures reproducibility:
- πΈ Snapshot: Contains exact versions of ALL dependencies (including transitive dependencies)
- π Locked versions: Anyone running
pixi install
gets the identical environment - π Cross-platform: Includes platform-specific dependency resolution
- β»οΈ Update control: Dependencies only change when you run
pixi update
or modifypixi.toml
Think of it as: A detailed receipt of your exact environment that guarantees the same setup on any machine.
platforms = ["win-64", "linux-64"]
This declaration:
- β Generates lock file entries for both Windows and Linux (64-bit)
- π₯οΈ Allows the same
pixi.toml
to work on both platforms - π Enables collaboration across different operating systems
- π¦ Pixi automatically uses the correct platform when installing
Common platforms:
win-64
: Windows 64-bitlinux-64
: Linux 64-bitosx-64
: macOS Intelosx-arm64
: macOS Apple Silicon
PyTorch with CUDA can be tricky. Here are two approaches used in this repository:
Install PyTorch via conda and specify CUDA requirements:
[dependencies]
pytorch = ">=2.7.1,<3"
[system-requirements]
cuda = "12.8"
Used in: cellpose, micro_sam, trackastra, biapy
Pros:
- β Cleaner dependency resolution
- β CUDA compatibility handled automatically
- β Better integration with conda packages
For some packages that require pip-installed PyTorch:
[pypi-dependencies]
torch = "*"
torchvision = "*"
[pypi-options]
extra-index-urls = ["https://download.pytorch.org/whl/cu118"]
index-strategy = "unsafe-best-match"
Used in: CAREamics (for compatibility with specific dependencies)
Pros:
- β Access to latest PyPI releases
- β Better compatibility with PyPI-only packages
- β Custom CUDA versions via wheel URLs
When to use PyPI approach:
- Package explicitly requires pip-installed PyTorch
- Need a specific PyTorch version not available in conda
- Compatibility issues with conda PyTorch build
πͺ Windows users: PyTorch CUDA support requires:
- Compatible NVIDIA GPU
- Updated NVIDIA drivers
- Matching CUDA toolkit version (handled by pixi via
system-requirements
) - Correct PyTorch wheel for your CUDA version
Tip: Always run pixi run test-cuda
after installation to verify GPU detection.
# Clean and reinstall
pixi clean
pixi install
- Ensure NVIDIA drivers are up to date
- Check system CUDA version matches
pixi.toml
requirements - Run
pixi run test-cuda
to diagnose
- Check
pixi.toml
for version constraints - Update pixi:
pixi self-update
Contributions, suggestions, and improvements are welcome!
- π‘ Have a suggestion? Open an issue to propose new tools or improvements
- π Found a bug? Report it via issues
- β¨ Want to add a new AI tool? Contributions are appreciated! Feel free to submit a pull request
Maarten Paul (m.w.paul@lumc.nl)