Skip to content
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

[BUG] Interoperability of cuML (confusion matrix) with torch arrays #3753

Open
divyegala opened this issue Apr 15, 2021 · 2 comments
Open

[BUG] Interoperability of cuML (confusion matrix) with torch arrays #3753

divyegala opened this issue Apr 15, 2021 · 2 comments
Labels
bug Something isn't working inactive-30d inactive-90d

Comments

@divyegala
Copy link
Member

divyegala commented Apr 15, 2021

Splitting from #3567. Bug has got to do with interoperability of cuml's confusion matrix with torch arrays. However, testing for this is likely to go beyond just confusion matrix.

Adding to this bug:

Code:

from cuml.metrics import confusion_matrix
print(confusion_matrix(y_true=labels.type(dtype=torch.int32).to(device),
                                   y_pred=pred.argmax(1).type(dtype=torch.int32).to(device)
                                   ))
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-23-b32704b34c7b> in <module>
     20 
     21     print(confusion_matrix(y_true=labels.type(dtype=torch.int32).to(device),
---> 22                            y_pred=pred.argmax(1).type(dtype=torch.int32).to(device)))


/opt/conda/envs/rapids/lib/python3.7/site-packages/cuml/internals/api_decorators.py in inner_with_getters(*args, **kwargs)
    464 
    465                 # Call the function
--> 466                 ret_val = func(*args, **kwargs)
    467 
    468             return cm.process_return(ret_val)

/opt/conda/envs/rapids/lib/python3.7/site-packages/cuml/metrics/confusion_matrix.py in confusion_matrix(y_true, y_pred, labels, sample_weight, normalize)
     67 
     68     if labels is None:
---> 69         labels = sorted_unique_labels(y_true, y_pred)
     70         n_labels = len(labels)
     71     else:

/opt/conda/envs/rapids/lib/python3.7/site-packages/cuml/metrics/utils.py in sorted_unique_labels(*ys)
     22     labels."""
     23     ys = (cp.unique(y) for y in ys)
---> 24     labels = cp.unique(cp.concatenate(ys))
     25     return labels

/opt/conda/envs/rapids/lib/python3.7/site-packages/cupy/manipulation/join.py in concatenate(tup, axis, out)
     55         tup = [m.ravel() for m in tup]
     56         axis = 0
---> 57     return core.concatenate_method(tup, axis, out)
     58 
     59 

cupy/core/_routines_manipulation.pyx in cupy.core._routines_manipulation.concatenate_method()

cupy/core/_routines_manipulation.pyx in cupy.core._routines_manipulation.concatenate_method()

/opt/conda/envs/rapids/lib/python3.7/site-packages/cuml/metrics/utils.py in <genexpr>(.0)
     21     """Extract an ordered array of unique labels from one or more arrays of
     22     labels."""
---> 23     ys = (cp.unique(y) for y in ys)
     24     labels = cp.unique(cp.concatenate(ys))
     25     return labels

/opt/conda/envs/rapids/lib/python3.7/site-packages/cupy/manipulation/add_remove.py in unique(ar, return_index, return_inverse, return_counts, axis)
    110         aux = ar[perm]
    111     else:
--> 112         ar.sort()
    113         aux = ar
    114     mask = cupy.empty(aux.shape, dtype=cupy.bool_)

cupy/core/core.pyx in cupy.core.core.ndarray.sort()

cupy/core/core.pyx in cupy.core.core.ndarray.sort()

cupy/core/_routines_sorting.pyx in cupy.core._routines_sorting._ndarray_sort()

cupy/cuda/thrust.pyx in cupy.cuda.thrust.sort()

RuntimeError: radix_sort: failed on 1st step: cudaErrorInvalidDevice: invalid device ordinal
Code that does work by converting torch.tensor with .cpu():

from sklearn.metrics import confusion_matrix
 
 print(confusion_matrix(y_true=labels.type(dtype=torch.int32).cpu(),
                                    y_pred=pred.argmax(1).type(dtype=torch.int32).cpu()
                                    ))
                                    
[[1      2]
 [  3      4]]
@divyegala divyegala added bug Something isn't working ? - Needs Triage Need team to review and classify labels Apr 15, 2021
@Nanthini10 Nanthini10 removed the ? - Needs Triage Need team to review and classify label Apr 26, 2021
@github-actions
Copy link

This issue has been labeled inactive-30d due to no recent activity in the past 30 days. Please close this issue if no further response or action is needed. Otherwise, please respond with a comment indicating any updates or changes to the original issue and/or confirm this issue still needs to be addressed. This issue will be labeled inactive-90d if there is no activity in the next 60 days.

@github-actions
Copy link

This issue has been labeled inactive-90d due to no recent activity in the past 90 days. Please close this issue if no further response or action is needed. Otherwise, please respond with a comment indicating any updates or changes to the original issue and/or confirm this issue still needs to be addressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working inactive-30d inactive-90d
Projects
None yet
Development

No branches or pull requests

2 participants