GPU-accelerated tractography package
Project description
GPUStreamlines
Installation
To install from pypi:
pip install "cuslines[cu13]" # CUDA 13 (NVIDIA)
pip install "cuslines[cu12]" # CUDA 12 (NVIDIA)
pip install "cuslines[metal]" # Apple Metal (Apple Silicon)
pip install "cuslines[webgpu]" # WebGPU (cross-platform: NVIDIA, AMD, Intel, Apple)
To install from dev:
pip install ".[cu13]" # CUDA 13
pip install ".[cu12]" # CUDA 12
pip install ".[metal]" # Apple Metal
pip install ".[webgpu]" # WebGPU (any GPU)
Running the examples
This repository contains several example usage scripts.
The script run_gpu_streamlines.py demonstrates how to run any diffusion MRI dataset on the GPU. It can also run on the CPU for reference, if the argument --device=cpu is used. If no data is passed, it will download and use the HARDI dataset.
To run the baseline CPU example on a random set of 1000 seeds, this is the command and example output:
$ python run_gpu_streamlines.py --device=cpu --output-prefix small --nseeds 1000
parsing arguments
Fitting Tensor
Computing anisotropy measures (FA,MD,RGB)
slowadcodf
Bootstrap direction getter
streamline gen
Generated 2746 streamlines from 1000 seeds, time: 6.713643550872803 s
Saved streamlines to small.1_1.trk, time 0.22669768333435059 s
Completed processing 1000 seeds.
Initialization time: 12.355878829956055 sec
Streamline generation total time: 6.9404990673065186 sec
Streamline processing: 6.713643550872803 sec
File writing: 0.22669768333435059 sec
To run the same case on a single GPU, this is the command and example output:
$ python run_gpu_streamlines.py --output-prefix small --nseeds 1000 --ngpus 1
parsing arguments
Fitting Tensor
Computing anisotropy measures (FA,MD,RGB)
slowadcodf
Bootstrap direction getter
streamline gen
Creating GPUTracker with 1 GPUs...
Generated 2512 streamlines from 1000 seeds, time: 0.21228599548339844 s
Saved streamlines to small.1_1.trk, time 0.17112255096435547 s
Completed processing 1000 seeds.
Initialization time: 14.81659483909607 sec
Streamline generation total time: 0.3834989070892334 sec
Streamline processing: 0.21228599548339844 sec
File writing: 0.17112255096435547 sec
Destroy GPUTracker...
Note that if you experience memory errors, you can adjust the --chunk-size flag.
To run on more seeds, we suggest setting the --write-method trx flag in the GPU script to not get bottlenecked by writing files.
GPU vs CPU differences
GPU backends (CUDA, Metal, and WebGPU) operate in float32 while DIPY uses float64. This causes slightly different peak selection at fiber crossings where ODF peaks have similar magnitudes. In practice the GPU produces comparable streamline counts and commissural fiber density, with modestly longer fibers on average. See cuslines/webgpu/README.md for cross-platform benchmarks and cuslines/metal/README.md for Metal-specific details.
The WebGPU backend runs on any GPU (NVIDIA, AMD, Intel, Apple) via wgpu-py. It is auto-detected when no vendor-specific backend is available. See python -m cuslines.webgpu.benchmark for a self-contained benchmark across all available backends.
Running on AWS with Docker
First, set up an AWS instance with GPU and ssh into it (we recommend a P3 instance with at least 1 V100 16 GB GPU and a Deep Learning AMI Ubuntu 18.04 v 33.0.). Then do the following:
- Log in to GitHub docker registry:
$ docker login -u <github id> docker.pkg.github.com
- Enter your GitHub access token. If you do not have one, create it on the GitHub general security settings page and enable package read access for that token.
- Pull the container:
$ docker pull docker.pkg.github.com/dipy/gpustreamlines/gpustreamlines:latest
- Run the code, mounting the current directory into the container for easy result retrieval:
$ docker run --gpus=all -v ${PWD}:/opt/exec/output:rw -it docker.pkg.github.com/dipy/gpustreamlines/gpustreamlines:latest \
python /opt/GPUStreamlines/run_gpu_streamlines.py --ngpus 1 --output-prefix /opt/exec/output/hardi_gpu_full
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cuslines-2.2.tar.gz.
File metadata
- Download URL: cuslines-2.2.tar.gz
- Upload date:
- Size: 156.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01e75d81988c84c4d563859b28849fca2f5a93f463e0020d25406bb8e23a9f11
|
|
| MD5 |
b0ab5d773967ae5214220320f95f06bf
|
|
| BLAKE2b-256 |
81cc242be8115f84f41e121502d29fdf091653bbaeea83f35058bcd26b1f2899
|
Provenance
The following attestation bundles were made for cuslines-2.2.tar.gz:
Publisher:
publish_pypi.yml on dipy/GPUStreamlines
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cuslines-2.2.tar.gz -
Subject digest:
01e75d81988c84c4d563859b28849fca2f5a93f463e0020d25406bb8e23a9f11 - Sigstore transparency entry: 1463444098
- Sigstore integration time:
-
Permalink:
dipy/GPUStreamlines@d8fecca71c35619d042e90f22f04268ad5dca38a -
Branch / Tag:
refs/tags/v2.2 - Owner: https://github.com/dipy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_pypi.yml@d8fecca71c35619d042e90f22f04268ad5dca38a -
Trigger Event:
release
-
Statement type:
File details
Details for the file cuslines-2.2-py3-none-any.whl.
File metadata
- Download URL: cuslines-2.2-py3-none-any.whl
- Upload date:
- Size: 169.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
070b99edc5da4379337476479713f4bd0708569add2fce0be4b1e2be919b4a37
|
|
| MD5 |
252f141a0c2a98928ad6dc755a9f895a
|
|
| BLAKE2b-256 |
c59beab0744efc1ce1b071e2eb77405f5edca5df6772e0fda7c5c48a1db28d6b
|
Provenance
The following attestation bundles were made for cuslines-2.2-py3-none-any.whl:
Publisher:
publish_pypi.yml on dipy/GPUStreamlines
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cuslines-2.2-py3-none-any.whl -
Subject digest:
070b99edc5da4379337476479713f4bd0708569add2fce0be4b1e2be919b4a37 - Sigstore transparency entry: 1463444123
- Sigstore integration time:
-
Permalink:
dipy/GPUStreamlines@d8fecca71c35619d042e90f22f04268ad5dca38a -
Branch / Tag:
refs/tags/v2.2 - Owner: https://github.com/dipy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_pypi.yml@d8fecca71c35619d042e90f22f04268ad5dca38a -
Trigger Event:
release
-
Statement type: