Usage¶
Using npbackend requires enabling the module and choosing a target.
Note
Since npbackend is integrated with Bohrium, the module name is bohrium and not npbackend.
Enabling npbackend¶
The least intrusive method of enabling bohrium is invoking your Python
program with the module loaded. Which means instead of invoking your
Python/NumPy program like this:
python my_program.py
You will invoke it like this instead:
python -m bohrium my_program.py
Which will effectively overrule the numpy module and instead use
bohrium. That is all it takes.
Another approach is replacing your import numpy statements with import bohrium. For example, replacing:
import numpy as np
With:
import bohrium as np
Choosing a npbackend target¶
npbackend will default to using Bohrium as the backend target. Changing
backend target is done via the NPBE_TARGET environment variable. Valid
values for NPBE_TARGET are:
- bhc, the default targeting Bohrium
- numexpr, targeting Numexpr
- pygpu, targeting libgpuarray
- numpy, Using NumPy itself through NumPy backend, this is most likely not something you would want to do, the value is only provided for testing purposes.
If you which to use something else than the default target, then you can invoke your Python/NumPy application with:
NPBE_TARGET="numexpr" python -m bohrium my_program.py
Or if your changed import statements:
NPBE_TARGET="numexpr" python my_program.py
That is all there is to it.