News for hackers. Stuff that matters.
Re:CuPy: NumPy and SciPy for GPU by johndough on Friday September 20, 2024 @03:34PM (#41604919)
> Isn't there a way to dynamically select between numpy and cupy, depending on whether you want cpu or gpu code?

CuPy is an (almost) drop-in replacement for NumPy, so the following works surprisingly often:

    if use_cpu:
        import numpy as np
    else:
       import cupy as np
Re:CuPy: NumPy and SciPy for GPU by gnulinux on Tuesday September 24, 2024 @09:49AM (#41636429)
> surprisingly

This is the problem with these kind of methods. It works, until it doesn't in an unknown way.