Skip to content

tornikeo/cudams

Repository files navigation

CudaMS

Hugging Face Spaces Static Badge Static Badge Static Badge

Calculate similarity between large number of mass spectra using a GPU. CudaMS aims to provide very fast replacements for commonly used similarity functions in matchms.

img

alt text

Note: CudaCosineGreedy uses fp32 format, wherease MatchMS uses fp64, and this difference causes most of the occasional errors.

Quickstart

Install:

pip install git+https://github.com/tornikeo/cudams

Use with MatchMS:

from matchms import calculate_scores
from matchms.importing import load_from_mgf
from cudams.similarity import CudaCosineGreedy

references = load_from_mgf(...)
queries = load_from_mgf(...)

kernel = CudaCosineGreedy()

scores = calculate_scores(
  references=references,
  queries=queries,
  similarity_function=kernel,
)
scores.scores_by_query(queries[42], 'CudaCosineGreedy_score', sort=True)

Supported similarity functions

  • CudaCosineGreedy, equivalent to CosineGreedy
  • CudaFingerprintSimilarity, equivalent to FingerprintSimilarity (jaccard, cosine, dice)
  • More coming soon - requests are welcome!

Installation

The easiest way to get started is to visit our huggingface space, which offers a simple UI, where you can upload a pair of MGF files and run similarity calculations there (we also offer some control over parameters).

Alternatively, you can use the colab notebook that has everything ready for you.

For local installations, we recommend using micromamba, it is much faster.

Total size of install in a fresh conda environment will be around 7-8GB (heaviest packages are pytorch, and cudatoolkit).

# Install cudatoolkit
conda install nvidia::cuda-toolkit -y

# Install torch (follow the official guide https://pytorch.org/get-started/locally/#start-locally)
conda install pytorch -c pytorch -c nvidia -y

# Install numba (follow the offical guide: https://numba.pydata.org/numba-doc/latest/user/installing.html#installing-using-conda-on-x86-x86-64-power-platforms)
conda install numba -y

# Install this repository
pip install git+https://github.com/tornikeo/cudams

Run in docker

The pytorch/pytorch:2.2.1-cuda12.1-cudnn8-devel has nearly everything you need. Once inside, do:

pip install git+https://github.com/tornikeo/cudams

Run on vast.ai

Use this template as a starting point, once inside, simply do:

pip install git+https://github.com/tornikeo/cudams