There has been some recent improvements to CPU-only mode (see #27).
When running test_topk.py as a script, it will first execute test_topk_small() and then iterate over function names starting with "test":
# put in function to debug manually
# TODO: remove this when vscode detects pytests properly
if __name__ == '__main__':
test_topk_small()
# Get the names of all functions in the global scope
function_names = [name for name, value in globals().items() if callable(value) and value.__module__ == '__main__' and name.startswith("test")]
# Iterate over the function names and call the functions
for name in function_names:
try:
globals()[name]()
print(f"passed {name}")
except AssertionError as e:
print(f"failed {name}: {e}")
The set of tests includes test_topk_platforms(), which attempts to run GPU-specific code irrespective of GPU availability.
For example in a CPU-only conda environment on Ubuntu:
(protax-gpu) @gwtaylor ➜ /workspaces/PROTAX-GPU (cpu-Linux) $ python tests/test_topk.py
test_topk_small: 0.028673410415649414s
Traceback (most recent call last):
File "/workspaces/PROTAX-GPU/tests/test_topk.py", line 134, in <module>
globals()[name]()
File "/workspaces/PROTAX-GPU/tests/test_topk.py", line 83, in test_topk_platforms
gpu_res = gpu_knn(N2S_SMALL.indptr, N2S_SMALL.indices, N2S_SMALL.data, N).block_until_ready()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: Unknown backend: 'gpu' requested, but no platforms that are instances of gpu are present. Platforms present are: cpu
--------------------
For simplicity, JAX has removed its internal frames from the traceback of the following exception. Set JAX_TRACEBACK_FILTERING=off to include these.
We see that test_topk_small successfully executes on the CPU but test_topk_platforms attempts to use the GPU and errors out.
The code should use some of the conditional logic used in #27 to determine if a GPU is available and not execute GPU-specific tests if a GPU is unavailable.
There has been some recent improvements to CPU-only mode (see #27).
When running
test_topk.py
as a script, it will first executetest_topk_small()
and then iterate over function names starting with "test":The set of tests includes
test_topk_platforms()
, which attempts to run GPU-specific code irrespective of GPU availability.For example in a CPU-only conda environment on Ubuntu:
We see that
test_topk_small
successfully executes on the CPU buttest_topk_platforms
attempts to use the GPU and errors out.The code should use some of the conditional logic used in #27 to determine if a GPU is available and not execute GPU-specific tests if a GPU is unavailable.