Import cupy
and cuML's NearestNeighbors
estimator
import cupy
from cuml.neighbors import NearestNeighbors
Set up some variables and create some random data on GPU
k = 5
n_samples = 100
n_features = 100
X = cupy.random.random((n_samples, n_features))
Execute k-Nearest Neighbors to find neighborhoods
knn = NearestNeighbors(n_neighbors=k)
knn.fit(X)
distances, indices = knn.kneighbors(X)
Create symmetrized KNN graph from our output arrays
distances = distances.reshape(n_samples * k)
indices = indices.reshape(n_samples * k)
indptr = cupy.arange(0, (k*n_samples)+1, k)
knn_graph = cupy.sparse.csr_matrix((distances, indices, indptr), shape=(n_samples, n_samples)).get()
knn_graph_symmetrized = knn_graph.maximum(knn_graph.T)
my n_samples = 100000
n_features = 400
Could that cause the issue. I have 1d tuples for the inputs in last but second step, but still getting the error. That is the only diff i see, you have n_samples and n_features both = 1000.