src-d / kmcuda

Large scale K-means and K-nn implementation on NVIDIA GPU / CUDA
Other
807 stars 146 forks source link

RuntimeError: cudaMemcpy failed #75

Closed Yuzz1020 closed 5 years ago

Yuzz1020 commented 5 years ago

Hello,

Great work, thanks for sharing this code! But I have encountered this error when running.

I'm using the random data generated with numpy to run the K-Means algorithm, but it keeps coming with this error

step 1cudaMemcpyAsync( host_dists + offset, (*dists)[devi].get(), length * sizeof(float), cudaMemcpyDeviceToHost)
/home/zzyu/kmcuda/src/kmeans.cu:814 -> invalid argument 

kmeans_cuda_plus_plus failed 
kmeans_init_centroids() failed for yinyang groups: invalid argument 
kmeans_cuda_yy failed: no error
Traceback (most recent call last):
  File "km_test.py", line 7, in <module>
    cen, ind = kmeans_cuda(arr, 512*256, verbosity=2, seed=3, yinyang_t=0.01) 
RuntimeError: cudaMemcpy failed

The random data I used has dimension [512512, 9] and the cluster center number is 256512 Any idea why this happens?

Thanks

vmarkovtsev commented 5 years ago

There are way too many clusters for km++ initialization method. Besides, try setting yinyang_t to 0. In any case, there is no bug in the code, so closing.