Skip to content

Upgrade cuML and cuDF #1395

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions Dockerfile.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ ENV PROJ_LIB=/opt/conda/share/proj
# the remaining pip commands: https://www.anaconda.com/using-pip-in-a-conda-environment/
RUN conda config --add channels nvidia && \
conda config --add channels rapidsai && \
conda config --set solver libmamba && \
# b/299991198 remove curl/libcurl install once DLVM base image includes version >= 7.86
conda install -c conda-forge mamba curl libcurl && \
# Base image channel order: conda-forge (highest priority), defaults.
Expand All @@ -107,24 +108,15 @@ RUN conda config --add channels nvidia && \
/tmp/clean-layer.sh

# Install spacy
# b/232247930: uninstall pyarrow to avoid double installation with the GPU specific version.
{{ if eq .Accelerator "gpu" }}
RUN mamba install -y -c conda-forge spacy cupy cuda-version=$CUDA_MAJOR_VERSION.$CUDA_MINOR_VERSION && \
RUN pip uninstall -y pyarrow && \
conda install -y -c conda-forge spacy cudf=24.4 cuml=24.4 cupy cuda-version=$CUDA_MAJOR_VERSION.$CUDA_MINOR_VERSION && \
/tmp/clean-layer.sh
{{ else }}
RUN pip install spacy && \
/tmp/clean-layer.sh
{{ end}}
{{ if eq .Accelerator "gpu" }}

# b/232247930: uninstall pyarrow to avoid double installation with the GPU specific version.
RUN pip uninstall -y pyarrow && \
mamba install -y cudf cuml && \
/tmp/clean-layer.sh

# TODO: b/296444923 - Resolve pandas dependency another way
RUN sed -i 's/^is_extension_type/# is_extension_type/g' /opt/conda/lib/python3.10/site-packages/cudf/api/types.py \
&& sed -i 's/^is_categorical/# is_categorical/g' /opt/conda/lib/python3.10/site-packages/cudf/api/types.py
{{ end }}

# Install PyTorch
{{ if eq .Accelerator "gpu" }}
Expand Down
9 changes: 9 additions & 0 deletions tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

import os
import unittest
import subprocess

def getAcceleratorName():
try:
deviceName = subprocess.check_output(['nvidia-smi', '--query-gpu=name', '--format=csv,noheader'])
return deviceName.decode('utf-8').strip();
except FileNotFoundError:
return("nvidia-smi not found.")

gpu_test = unittest.skipIf(len(os.environ.get('CUDA_VERSION', '')) == 0, 'Not running GPU tests')
p100_exempt = unittest.skipIf(getAcceleratorName() == "Tesla P100-PCIE-16GB", 'Not running p100 exempt tests')
tpu_test = unittest.skipIf(len(os.environ.get('ISTPUVM', '')) == 0, 'Not running TPU tests')
20 changes: 20 additions & 0 deletions tests/test_cudf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import unittest

from common import gpu_test, p100_exempt


class TestCudf(unittest.TestCase):
@gpu_test
@p100_exempt
def test_cudf_dataframe_operations(self):
import cudf

data = {'col1': [1, 2, 3], 'col2': [4, 5, 6]}
gdf = cudf.DataFrame({'col1': [1, 2, 3], 'col2': [4, 5, 6]})

gdf['col3'] = gdf['col1'] + gdf['col2']

expected_col3 = cudf.Series([5, 7, 9])
self.assertEqual(gdf.shape, (3, 2))
self.assertEqual(list(gdf.columns), ['col1', 'col2'])
self.assertTrue(gdf['col3'].equals(expected_col3))
19 changes: 19 additions & 0 deletions tests/test_cuml.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import unittest

from common import gpu_test, p100_exempt


class TestCuml(unittest.TestCase):
@gpu_test
@p100_exempt
def test_pca_fit_transform(self):
import unittest
import numpy as np
from cuml.decomposition import PCA

x = np.array([[1.0, 2.0], [2.0, 4.0], [3.0, 6.0], [-1.0, -2.0], [-2.0, -4.0]])
pca = PCA(n_components=1)

x_transformed = pca.fit_transform(x)

self.assertEqual(x_transformed.shape, (5, 1))
14 changes: 9 additions & 5 deletions tests/test_datashader.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import unittest

import numpy as np
import pandas as pd
import datashader as ds
import datashader.transfer_functions as tf
from common import p100_exempt

class TestDatashader(unittest.TestCase):
# based on https://github.com/pyviz/datashader/blob/master/datashader/tests/test_pipeline.py

@p100_exempt
def test_pipeline(self):
# based on https://github.com/pyviz/datashader/blob/master/datashader/tests/test_pipeline.py
import numpy as np
import pandas as pd
import datashader as ds
import datashader.transfer_functions as tf

df = pd.DataFrame({
'x': np.array(([0.] * 10 + [1] * 10)),
'y': np.array(([0.] * 5 + [1] * 5 + [0] * 5 + [1] * 5)),
Expand Down
10 changes: 7 additions & 3 deletions tests/test_geoviews.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import unittest

import geoviews.feature as gf
import holoviews as hv
from cartopy import crs
from common import p100_exempt

class TestGeoviews(unittest.TestCase):

@p100_exempt
def test_viz(self):
import geoviews.feature as gf
import holoviews as hv
from cartopy import crs

hv.extension('matplotlib')
(gf.ocean + gf.land + gf.ocean * gf.land * gf.coastline * gf.borders).options(
'Feature', projection=crs.Geostationary(), global_extent=True
Expand Down