Skip to content

Commit bb0b464

Browse files
committed
Merge remote-tracking branch 'origin/master' into cg
2 parents 1c4c18e + 366192c commit bb0b464

36 files changed

+985
-178
lines changed

.github/workflows/test-ci.yml

Lines changed: 113 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ env:
1616
PYTHON_VERSION: "3.10"
1717
BART_VERSION: "0.8.00"
1818
ref_backend: "finufft"
19+
create_venv: "python -m venv $RUNNER_WORKSPACE/venv"
20+
activate_venv: "source $RUNNER_WORKSPACE/venv/bin/activate"
21+
setup_cuda: "export CUDA_BIN_PATH=/usr/local/cuda-12.1/;export PATH=/usr/local/cuda-12.1/bin/:${PATH};export LD_LIBRARY_PATH=/usr/local/cuda-12.1/lib64/:${LD_LIBRARY_PATH}"
1922

2023
jobs:
2124
test-cpu:
@@ -44,28 +47,38 @@ jobs:
4447
- name: Install Python Deps
4548
shell: bash
4649
run: |
50+
python --version
51+
${{ env.create_venv }}
52+
${{ env.activate_venv }}
4753
python -m pip install --upgrade pip
4854
python -m pip install -e .[test]
4955
5056
- name: Install pynfft
5157
if: ${{ matrix.backend == 'pynfft' || env.ref_backend == 'pynfft' }}
5258
shell: bash
5359
run: |
60+
${{ env.activate_venv }}
5461
python -m pip install "pynfft2>=1.4.3"
5562
5663
- name: Install pynufft
5764
if: ${{ matrix.backend == 'pynufft-cpu' || env.ref_backend == 'pynufft-cpu' }}
58-
run: python -m pip install pynufft
65+
run: |
66+
${{ env.activate_venv }}
67+
python -m pip install pynufft
5968
6069
- name: Install finufft
6170
if: ${{ matrix.backend == 'finufft' || env.ref_backend == 'finufft'}}
6271
shell: bash
63-
run: python -m pip install finufft
72+
run: |
73+
${{ env.activate_venv }}
74+
python -m pip install finufft
6475
6576
- name: Install Sigpy
6677
if: ${{ matrix.backend == 'sigpy' || env.ref_backend == 'sigpy'}}
6778
shell: bash
68-
run: python -m pip install sigpy
79+
run: |
80+
${{ env.activate_venv }}
81+
python -m pip install sigpy
6982
7083
- name: Install BART
7184
if: ${{ matrix.backend == 'bart' || env.ref_backend == 'bart'}}
@@ -81,14 +94,17 @@ jobs:
8194
8295
- name: Install torchkbnufft-cpu
8396
if: ${{ matrix.backend == 'torchkbnufft-cpu' || env.ref_backend == 'torchkbnufft-cpu'}}
84-
run: python -m pip install torchkbnufft
97+
run: |
98+
${{ env.activate_venv }}
99+
python -m pip install torchkbnufft
85100
86101
87102
- name: Run Tests
88103
shell: bash
89104
run: |
105+
${{ env.activate_venv }}
90106
export COVERAGE_FILE=coverage_${{ matrix.backend }}
91-
pytest -k='operators' --backend ${{ matrix.backend }} --ref ${{ env.ref_backend }} --cov --disable-pytest-warnings --cov-branch --cov-report=term
107+
python -m pytest -k='operators' --backend ${{ matrix.backend }} --ref ${{ env.ref_backend }} --cov --disable-pytest-warnings --cov-branch --cov-report=term --durations=10
92108
- name: Upload coverage
93109
uses: actions/upload-artifact@v4
94110
with:
@@ -111,45 +127,41 @@ jobs:
111127
- name: Install mri-nufft and finufft
112128
shell: bash
113129
run: |
114-
cd $RUNNER_WORKSPACE
115-
python --version
116-
python -m venv venv
117-
source $RUNNER_WORKSPACE/venv/bin/activate
118-
pip install --upgrade pip wheel
119-
pip install -e mri-nufft[test]
120-
pip install cupy-cuda12x finufft "numpy<2.0"
130+
${{ env.create_venv }}
131+
${{ env.activate_venv }}
132+
python -m pip install --upgrade pip wheel
133+
python -m pip install -e .[test]
134+
python -m pip install cupy-cuda12x finufft "numpy<2.0"
121135
122136
- name: Install torch with CUDA 12.1
123137
shell: bash
124138
if: ${{ matrix.backend != 'tensorflow'}}
125139
run: |
126-
source $RUNNER_WORKSPACE/venv/bin/activate
127-
pip install torch
140+
${{ env.activate_venv }}
141+
${{ env.setup_cuda }}
142+
python -m pip install torch
128143
129144
- name: Install backend
130145
shell: bash
131146
run: |
132-
source $RUNNER_WORKSPACE/venv/bin/activate
133-
export CUDA_BIN_PATH=/usr/local/cuda-12.1/
134-
export PATH=/usr/local/cuda-12.1/bin/:${PATH}
135-
export LD_LIBRARY_PATH=/usr/local/cuda-12.1/lib64/:${LD_LIBRARY_PATH}
147+
${{ env.activate_venv }}
136148
if [[ ${{ matrix.backend }} == "torchkbnufft-gpu" ]]; then
137-
pip install torchkbnufft
149+
python -m pip install torchkbnufft
138150
elif [[ ${{ matrix.backend }} == "tensorflow" ]]; then
139-
pip install tensorflow-mri==0.21.0 tensorflow-probability==0.17.0 tensorflow-io==0.27.0 matplotlib==3.7
151+
python -m pip install tensorflow-mri==0.21.0 tensorflow-probability==0.17.0 tensorflow-io==0.27.0 matplotlib==3.7
140152
elif [[ ${{ matrix.backend }} == "cufinufft" ]]; then
141-
pip install "cufinufft<2.3"
153+
python -m pip install "cufinufft<2.3"
142154
else
143-
pip install ${{ matrix.backend }}
155+
python -m pip install ${{ matrix.backend }}
144156
fi
145157
146158
- name: Run Tests
147159
shell: bash
148160
run: |
161+
${{ env.activate_venv }}
149162
cd $RUNNER_WORKSPACE/mri-nufft
150-
source $RUNNER_WORKSPACE/venv/bin/activate
151163
export COVERAGE_FILE=coverage_${{ matrix.backend }}
152-
python -m pytest -k='operators' --ref ${{ env.ref_backend }} --backend ${{ matrix.backend }} --disable-pytest-warnings --cov --cov-branch --cov-report=term
164+
python -m pytest -k='operators' --ref ${{ env.ref_backend }} --backend ${{ matrix.backend }} --disable-pytest-warnings --cov --cov-branch --cov-report=term --durations=10
153165
154166
- name: Upload coverage
155167
if: success()
@@ -167,7 +179,54 @@ jobs:
167179
rm -rf finufft
168180
rm -rf gpuNUFFT
169181
rm -rf venv
170-
182+
183+
test-other:
184+
runs-on: [gpu]
185+
if: ${{ !contains(github.event.head_commit.message, '[style]') || github.ref == 'refs/heads/master' }}
186+
steps:
187+
- uses: actions/checkout@v4
188+
189+
- name: Install mri-nufft and finufft
190+
shell: bash
191+
run: |
192+
${{ env.create_venv }}
193+
${{ env.activate_venv }}
194+
python -m pip install --upgrade pip wheel
195+
python -m pip install -e .[test]
196+
python -m pip install cupy-cuda12x finufft "numpy<2.0"
197+
198+
- name: Install torch with CUDA 12.1
199+
shell: bash
200+
run: |
201+
${{ env.activate_venv }}
202+
${{ env.setup_cuda }}
203+
python -m pip install torch
204+
205+
- name: Run non operators tests
206+
shell: bash
207+
run: |
208+
${{ env.activate_venv }}
209+
export COVERAGE_FILE=coverage_other
210+
python -m pytest -n=4 -k "not operators" --cov --cov-branch --cov-report=term --durations=10 --disable-pytest-warnings
211+
212+
- name: Upload coverage
213+
if: success()
214+
uses: actions/upload-artifact@v4
215+
with:
216+
name: coverage_other
217+
path: coverage_other
218+
219+
- name: Cleanup
220+
if: always()
221+
shell: bash
222+
run: |
223+
cd $RUNNER_WORKSPACE
224+
ls -al
225+
rm -rf finufft
226+
rm -rf gpuNUFFT
227+
rm -rf venv
228+
229+
171230
get-commit-message:
172231
runs-on: ubuntu-latest
173232
outputs:
@@ -182,7 +241,7 @@ jobs:
182241
COMMIT_MESSAGE=$(git log -1 --pretty=%B)
183242
echo "Commit message $COMMIT_MESSAGE"
184243
echo "::set-output name=message::$COMMIT_MESSAGE"
185-
244+
186245
test-examples:
187246
runs-on: gpu
188247
needs: get-commit-message
@@ -205,23 +264,25 @@ jobs:
205264
- name: Install Python deps
206265
shell: bash
207266
run: |
267+
${{ env.create_venv }}
268+
${{ env.activate_venv }}
208269
python -m pip install --upgrade pip
209270
python -m pip install -e .[extra,test,dev]
210271
python -m pip install finufft pooch brainweb-dl torch fastmri
211-
272+
212273
- name: Install GPU related interfaces
213274
run: |
214-
export CUDA_BIN_PATH=/usr/local/cuda-12.1/
215-
export PATH=/usr/local/cuda-12.1/bin/:${PATH}
216-
export LD_LIBRARY_PATH=/usr/local/cuda-12.1/lib64/:${LD_LIBRARY_PATH}
275+
${{ env.activate_venv }}
276+
${{ env.setup_cuda }}
217277
pip install cupy-cuda12x torch
218278
python -m pip install gpuNUFFT "cufinufft<2.3" sigpy scikit-image fastmri
219279
220280
- name: Run examples
221281
shell: bash
222282
run: |
283+
${{ env.activate_venv }}
223284
export COVERAGE_FILE=coverage_plots
224-
pytest examples tests -k="not operators" --cov --cov-branch --cov-report=term
285+
python -m pytest examples -n=4 --cov --cov-branch --cov-report=term --durations=10
225286
226287
- name: Cache brainweb-dl directory
227288
uses: actions/cache/save@v4
@@ -256,16 +317,19 @@ jobs:
256317
uses: actions/setup-python@v5
257318
with:
258319
python-version: ${{ env.PYTHON_VERSION }}
259-
320+
260321
- name: add the coverage tool
261322
shell: bash
262323
run: |
324+
${{ env.create_venv }}
325+
${{ env.activate_venv }}
263326
python -m pip install --upgrade pip
264327
python -m pip install coverage[toml]
265328
python -m pip install -e .
266329
267330
- name: Combine coverage
268331
run: |
332+
${{ env.activate_venv }}
269333
export COVERAGE_FILE=coverage_combined
270334
coverage combine -a coverage_data/*
271335
@@ -277,6 +341,7 @@ jobs:
277341

278342
- name: Reports
279343
run: |
344+
${{ env.activate_venv }}
280345
export COVERAGE_FILE=coverage_combined
281346
coverage xml
282347
coverage report
@@ -302,7 +367,7 @@ jobs:
302367
steps:
303368
- name: Checkout
304369
uses: actions/checkout@v4
305-
370+
306371
- name: Get history and tags for SCM versioning to work
307372
run: |
308373
git fetch --prune --unshallow
@@ -312,30 +377,32 @@ jobs:
312377
uses: actions/setup-python@v5
313378
with:
314379
python-version: "3.10"
315-
380+
316381
- name: Install dependencies
317382
shell: bash -l {0}
318383
run: |
384+
${{ env.create_venv }}
385+
${{ env.activate_venv }}
319386
python -m pip install --upgrade pip
320-
python -m pip install .[doc]
387+
python -m pip install .[doc,extra]
321388
python -m pip install finufft
322-
389+
323390
- name: Install GPU related interfaces
324391
run: |
325-
export CUDA_BIN_PATH=/usr/local/cuda-12.1/
326-
export PATH=/usr/local/cuda-12.1/bin/:${PATH}
327-
export LD_LIBRARY_PATH=/usr/local/cuda-12.1/lib64/:${LD_LIBRARY_PATH}
392+
${{ env.activate_venv }}
393+
${{ env.setup_cuda }}
328394
pip install cupy-cuda12x torch
329-
python -m pip install gpuNUFFT "cufinufft<2.3"
330-
395+
python -m pip install gpuNUFFT "cufinufft<2.3" sigpy scikit-image fastmri
396+
331397
- name: Build API documentation
332398
run: |
399+
${{ env.activate_venv }}
333400
python -m sphinx docs docs_build
334-
401+
335402
- name: Display data
336403
run: ls -R
337404
working-directory: docs_build/_static
338-
405+
339406
- name: Upload artifact
340407
id: artifact-upload-step
341408
uses: actions/upload-artifact@v4
@@ -344,7 +411,7 @@ jobs:
344411
name: docs
345412
path: 'docs_build'
346413
retention-days: 5
347-
414+
348415
CompileDocs:
349416
name: Compile the coverage badge in docs
350417
runs-on: ubuntu-latest
@@ -357,14 +424,14 @@ jobs:
357424
name: docs
358425
path: docs_build
359426
overwrite: true
360-
427+
361428
- name: Get the badge from CI
362429
uses: actions/download-artifact@v4
363430
with:
364431
name: coverage_badge
365432
path: docs_build/_static
366433
github-token: ${{ secrets.GITHUB_TOKEN }}
367-
434+
368435
- name: ReUpload artifacts
369436
uses: actions/upload-artifact@v4
370437
with:

README.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Doing non-Cartesian MR Imaging has never been so easy.
99
:header-rows: 0
1010

1111
* - .. image:: https://mind-inria.github.io/mri-nufft/_static/coverage_badge.svg
12-
- .. image:: https://github.com/mind-inria/mri-nufft/workflows/CI/badge.svg
12+
- .. image:: https://github.com/mind-inria/mri-nufft/actions/workflows/test-ci.yml/badge.svg
1313
- .. image:: https://github.com/mind-inria/mri-nufft/workflows/CD/badge.svg
1414
* - .. image:: https://img.shields.io/badge/style-black-black
1515
- .. image:: https://img.shields.io/badge/docs-Sphinx-blue
@@ -55,6 +55,7 @@ Usage
5555
5656
## The real deal starts here ##
5757
# Choose your NUFFT backend (installed independently from the package)
58+
# pip install mri-nufft[finufft] will be just fine here
5859
NufftOperator = mrinufft.get_operator("finufft")
5960
6061
# For improved image reconstruction, use density compensation
@@ -88,6 +89,10 @@ MRI-nufft is available on Pypi and can be installed with::
8889
pip install mri-nufft
8990

9091
Additionally, you will have to install at least one NUFFT computation backend. See the `Documentation <https://mind-inria.github.io/mri-nufft/getting_started.html#choosing-a-nufft-backend>`_ for more guidance.
92+
Typically we recommend::
93+
94+
pip install mri-nufft[finufft]
95+
pip install mri-nufft[cufinufft] # if you have a NVIDIA GPU and CUDA>=12
9196

9297

9398
Benchmark

docs/getting_started.rst

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,18 @@ If you want to modifiy the mri-nufft code base
2424
Choosing a NUFFT Backend
2525
========================
2626

27-
In order to perform Non-Uniform fast Fourier transform you need to install a specific backend library.
27+
In order to perform Non-Uniform fast Fourier transform you need to install a specific :ref:`NUFFT` computation library backend.
28+
29+
.. tip::
30+
31+
TLDR: If you have a GPU and CUDA>=12.0, you probably want to install MRI-NUFFT like so:
32+
``pip install mri-nufft[cufinufft]`` or ``pip install mri-nufft[gpunufft]``
33+
For CPU only setup we recommend ``pip install mri-nufft[finufft]``
34+
35+
Then, use the ``get_operator(backend=<your backend>, ... )`` to initialize your MRI-NUFFT operator.
36+
37+
For more information , check the :ref:`Examples`
38+
2839

2940
Supported Libraries
3041
-------------------
@@ -116,8 +127,9 @@ PyNFFT requires Cython<3.0.0 to work. and can be installed using
116127
117128
Which backend to use
118129
--------------------
119-
[TBA] See the benchmark. Fastest are gpunufft and cufinufft (because they are using gpu). Additionally, Gunufft is usually more memory efficient.
120130

131+
We provided an extensive benchmark on computation and memory usage on https://github.com/mind-inria/mri-nufft-benchmark/
132+
133+
.. tip::
121134

122-
.. note::
123-
if you are using pytorch gpu-array, you can only use cufinufft.
135+
Overall, we recommend to use ``finufft`` for CPU, and ``cufinufft`` or ``gpunufft`` when CUDA GPU are available.

0 commit comments

Comments
 (0)