How to compile CUBLAS?

I’ve been writing CUDA code and it’s going well. I need to do some matrix-vector multiplication and I read that using the CUBLAS library might be the way to go, I’d like to compare my CUDA version with one using CUBLAS but I can’t get CUBLAS code to compile.

I’ve copied the C code example from the CUBLAS manual into a file with .cu extension and tried nvcc code.cu but all I get is undefined symbol error for every CUBLAS function in the code. I’m using a mac here, but have linux at work too. I’m guessing I need to set some link option but can’t seem to find any reference to that?

Cheers

CUBLAS is a supplied as a library. It requires no compilation. Just compile your code with the standard host compiler and link it with the CUBLAS library (it is supplied in the toolkit: libcublas.so for linux and cublas.dylib for Mac OS X). If you are trying to call CUBLAS functions inside your own kernel code, you can’t.

Try 'nvcc -lcublas"

Brilliant, thanks that did it

2 Likes