From 40624affd42b3bdb2cedd616391a2e5e32d5473f Mon Sep 17 00:00:00 2001 From: mrava87 Date: Mon, 16 Jun 2025 21:14:05 +0100 Subject: [PATCH] build: added make rules for tests on gpu and more on documentation --- CONTRIBUTING.md | 6 ++++++ Makefile | 13 ++++++++++++- docs/source/contributing.rst | 7 +++++++ docs/source/gpu.rst | 14 ++++++++++++++ 4 files changed, 39 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b2792a5e7..58ce812c6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -63,6 +63,12 @@ that the both old and new tests pass successfully: make tests ``` +If you have access to a GPU, it is advised also that old and new tests run with the CuPy +backend pass successfully: + ``` + make tests_gpu + ``` + 4. Run flake8 to check the quality of your code: ``` make lint diff --git a/Makefile b/Makefile index 8ae376e78..56355e51b 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ PIP := $(shell command -v pip3 2> /dev/null || command which pip 2> /dev/null) PYTHON := $(shell command -v python3 2> /dev/null || command which python 2> /dev/null) -.PHONY: install dev-install dev-install_gpu install_conda dev-install_conda dev-install_conda_arm tests doc docupdate servedoc lint typeannot coverage +.PHONY: install dev-install dev-install_gpu install_conda dev-install_conda dev-install_conda_arm tests tests_cpu_ongpu tests_gpu doc docupdate servedoc lint typeannot coverage pipcheck: ifndef PIP @@ -42,9 +42,20 @@ dev-install_conda_gpu: conda env create -f environment-dev-gpu.yml && conda activate pylops_gpu && pip install -e . tests: + # Run tests with CPU make pythoncheck pytest +tests_cpu_ongpu: + # Run tests with CPU on a system with GPU (and CuPy installed) + make pythoncheck + export CUPY_PYLOPS=0 && export TEST_CUPY_PYLOPS=0 && pytest + +tests_gpu: + # Run tests with GPU (requires CuPy to be installed) + make pythoncheck + export TEST_CUPY_PYLOPS=1 && pytest + doc: cd docs && rm -rf source/api/generated && rm -rf source/gallery &&\ rm -rf source/tutorials && rm -rf build && make html && cd .. diff --git a/docs/source/contributing.rst b/docs/source/contributing.rst index 6be387a69..600eb8daf 100755 --- a/docs/source/contributing.rst +++ b/docs/source/contributing.rst @@ -75,6 +75,13 @@ that the both old and new tests pass successfully: >> make tests +If you have access to a GPU, it is advised also that old and new tests run with the CuPy +backend pass successfully: + +.. code-block:: bash + + >> make tests_gpu + 4. Run flake8 to check the quality of your code: .. code-block:: bash diff --git a/docs/source/gpu.rst b/docs/source/gpu.rst index 842770b29..487786694 100755 --- a/docs/source/gpu.rst +++ b/docs/source/gpu.rst @@ -32,6 +32,20 @@ be also wrapped into a :class:`pylops.JaxOperator`. See below for a comphrensive list of supported operators and additional functionalities for both the ``cupy`` and ``jax`` backends. +Install dependencies +-------------------- +GPU-enabled development environments can created using ``conda`` + +.. code-block:: bash + + >> make dev-install_conda_gpu + +or ``pip`` + +.. code-block:: bash + + >> make dev-install_gpu + Examples --------