> 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