diff --git a/ci/test_python.sh b/ci/test_python.sh index 5175696975d..ec28028974e 100755 --- a/ci/test_python.sh +++ b/ci/test_python.sh @@ -91,6 +91,60 @@ pytest \ cugraph/pytest-based/bench_algos.py popd +if [[ "${RAPIDS_CUDA_VERSION}" == "11.8.0" ]]; then + if [[ "${RUNNER_ARCH}" != "ARM64" ]]; then + # we are only testing in a single cuda version + # because of pytorch and rapids compatibilty problems + rapids-mamba-retry env create --force -f env.yaml -n test_cugraph_dgl + + # activate test_cugraph_dgl environment for dgl + set +u + conda activate test_cugraph_dgl + set -u + rapids-mamba-retry install \ + --channel "${CPP_CHANNEL}" \ + --channel "${PYTHON_CHANNEL}" \ + --channel pytorch \ + --channel pytorch-nightly \ + --channel dglteam/label/cu117 \ + --channel nvidia \ + libcugraph \ + pylibcugraph \ + cugraph \ + cugraph-dgl \ + 'dgl>=1.0' \ + 'pytorch>=2.0' \ + 'pytorch-cuda>=11.8' + + rapids-print-env + + rapids-logger "pytest cugraph_dgl (single GPU)" + pushd python/cugraph-dgl/tests + pytest \ + --cache-clear \ + --ignore=mg \ + --ignore=nn \ + --junitxml="${RAPIDS_TESTS_DIR}/junit-cugraph-dgl.xml" \ + --cov-config=../../.coveragerc \ + --cov=cugraph_dgl \ + --cov-report=xml:"${RAPIDS_COVERAGE_DIR}/cugraph-dgl-coverage.xml" \ + --cov-report=term \ + . + popd + + # Reactivate the test environment back + set +u + conda deactivate + conda activate test + set -u + else + rapids-logger "skipping cugraph_dgl pytest on ARM64" + fi +else + rapids-logger "skipping cugraph_dgl pytest on CUDA!=11.8" +fi + + rapids-logger "pytest cugraph_pyg (single GPU)" pushd python/cugraph-pyg/cugraph_pyg # rmat is not tested because of multi-GPU testing diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index ed6c9918221..82e2a8a278a 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -37,7 +37,6 @@ dependencies: - notebook>=0.5.0 - numpydoc - nvcc_linux-64=11.8 -- ogb - openmpi - pip - pre-commit diff --git a/dependencies.yaml b/dependencies.yaml index 1ca6fcff75b..15c98bbe884 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -203,7 +203,6 @@ dependencies: common: - output_types: [conda, requirements] packages: - - ogb - py - pytest - pytest-cov diff --git a/python/cugraph-dgl/cugraph_dgl/dataloading/utils/sampling_helpers.py b/python/cugraph-dgl/cugraph_dgl/dataloading/utils/sampling_helpers.py index 69f2ed1c4a3..288b4759752 100644 --- a/python/cugraph-dgl/cugraph_dgl/dataloading/utils/sampling_helpers.py +++ b/python/cugraph-dgl/cugraph_dgl/dataloading/utils/sampling_helpers.py @@ -21,6 +21,11 @@ def cast_to_tensor(ser: cudf.Series): + if len(ser) == 0: + # Empty series can not be converted to pytorch cuda tensor + t = torch.from_numpy(ser.values.get()) + return t.to("cuda") + return torch.as_tensor(ser.values, device="cuda") diff --git a/python/cugraph-dgl/tests/test_utils.py b/python/cugraph-dgl/tests/test_utils.py new file mode 100644 index 00000000000..cee255d85b0 --- /dev/null +++ b/python/cugraph-dgl/tests/test_utils.py @@ -0,0 +1,25 @@ +# Copyright (c) 2022-2023, NVIDIA CORPORATION. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import cudf +import cupy as cp +import torch + +from cugraph_dgl.dataloading.utils.sampling_helpers import cast_to_tensor + + +def test_casting_empty_array(): + ar = cp.zeros(shape=0, dtype=cp.int32) + ser = cudf.Series(ar) + output_tensor = cast_to_tensor(ser) + assert output_tensor.dtype == torch.int32