def test_gds(gds_enabled, cuda_lib): lib = pytest.importorskip(cuda_lib) if cuda_lib == "cupy": data_create = lambda: lib.arange(10) data_compare = lambda x, y: all(x == y) elif cuda_lib == "cudf": data_create = lambda: lib.Series(range(10)) data_compare = lambda x, y: all((x == y).values_host) elif cuda_lib == "numba.cuda": data_create = lambda: lib.to_device(range(10)) data_compare = lambda x, y: all(x.copy_to_host() == y.copy_to_host()) try: ProxifyHostFile.register_disk_spilling() if gds_enabled and not ProxifyHostFile._gds_enabled: pytest.skip("GDS not available") a = data_create() header, frames = serialize(a, serializers=("disk", )) b = deserialize(header, frames) assert type(a) == type(b) assert data_compare(a, b) finally: ProxifyHostFile.register_disk_spilling() # Reset disk spilling options
import dask import dask.array from dask.dataframe.core import has_parallel_type from dask.sizeof import sizeof from distributed import Client from distributed.protocol.serialize import deserialize, serialize import dask_cudf import dask_cuda from dask_cuda import proxy_object from dask_cuda.proxify_device_objects import proxify_device_objects from dask_cuda.proxify_host_file import ProxifyHostFile ProxifyHostFile.register_disk_spilling( ) # Make the "disk" serializer available @pytest.mark.parametrize("serializers", [None, ("dask", "pickle"), ("disk", )]) def test_proxy_object(serializers): """Check "transparency" of the proxy object""" org = bytearray(range(10)) pxy = proxy_object.asproxy(org, serializers=serializers) assert len(org) == len(pxy) assert org[0] == pxy[0] assert 1 in pxy assert 10 not in pxy assert str(org) == str(pxy) assert "dask_cuda.proxy_object.ProxyObject at " in repr(pxy)