Ground-state calculations on a GPU is an experimental feature at the moment with some limitations:
it has only been implemented in the new GPAW
only parallelization over k-points
See gpaw/test/gpu/test_pw.py for an example.
>>> import numpy as np >>> from gpaw.gpu import cupy as cp >>> a_cpu = np.zeros(...) >>> a_gpu = cp.asarray(a_cpu) # from CPU to GPU >>> b_cpu = a_gpu.get() # from GPU to CPU
The gpaw.gpu module¶
- gpaw.gpu.is_hip = False¶
True if we are using HIP
Transfer array to CPU (if not already there).
array (numpy.ndarray | gpaw.gpu.cpupy.ndarray) – Numpy or CuPy array.
- gpaw.gpu.as_xp(array, xp)¶
Transfer array to CPU or GPU (if not already there).
- gpaw.gpu.cupy_eigh(a, UPLO)¶
HIP-GPU version is too slow for now so we do it on the CPU.
Fake cupy library¶
The implementation uses cupy. In the code, we don’t do
import cupy as cp.
Instead we use
from gpaw.gpu import cupy as cp. This allows us to use a
cupy implementation so that we can run GPAW’s
cupy code without
having a physical GPU. To enable the fake
cupy module, do:
GPAW_CPUPY=1 python ...
This allows users without a GPU to find out if their code interferes with the GPU implementation, simply by running the tests.
CuPy enabled container objects¶
The following objects:
object can do its operations on the GPU.
Use a GPU-aware MPI implementation and set the
GPAW_GPU when compiling