Posts

Showing posts from March, 2011

K-means on CUDA with CUV [edit]

Since I felt that our CUDA library, CUV, was a little lifeless without some examples on how it can be used, I started to work on a K-means implementation using it. The idea is to have something like from cuv_python import kmeans [clusters, assignements]=kmeans(data) run k-means on the GPU. There are some papers on kmeans on the GPU out there but I thought I see how far a little coding will get me. As an (maybe a little atypical) example, I choose MNIST as a dataset. My experiments were with k=10 or k=20 but this should not be a restriction on the implementation. First, I tried to do it without adding anything to CUV, just using simple matrix operations that were already there. The result is something like this: clusters=mnist[:,rand_indices] mnist_dev=cp.push(mnist) # copy('F') is necessary so we can slice later on clusters_dev=cp.push(clusters.copy("F")) norms = cp.dev_matrix_cmf(mnist_dev.w, 1) cp.reduce_to_row(norms.vec,mnist_dev,cp.reduce_functor.ADD_S

Finding a Function by its Symbol

This one is from the live of a C++ programmer. As you might remember, I am working on the CUV Library for CUDA programming in Python. The library uses quite a lot of templates and meta-programming. Since we want to have all functionality in Python, we need to instantiate all the templates. After some refactoring, I got the helpful error message _cuv_python.so: undefined symbol: _ZN3cuv6detail20apply_binary_functorINS_6vectorIfNS_16dev_memory_spaceEjEES4_NS2_IhS3_jEEhEEvRT_RKT0_RKT1_RKNS_13BinaryFunctorERKiRKT2_SL_ Ah, right. That one. Well, often it is possible to guess which function this is about. But since the instantiations are not so straight-forward, I had no idea which function that was. So I wanted to look that up somehow. I tried to google how to find the corresponding function, but without much success. Probably I was missing the right keywords. After some fiddling around, I finally got it: Load your program/library in gdb. You can get a list of all symbols in t