cublasInit () fails

Hi everybody,

I’m trying to implement a CG algorithm for band-matrices in cuda and cublas.
The only thing i did with cuda is an element-wise vector vector multiplication (which i need for fast matrix - vector multiplications of the band matrices).

But the most simple thing does"t work like i would expect it to :)

cublasStatus status = cublasInit();
if (status != CUBLAS_STATUS_SUCCESS) {
std::cout <<“ERORR: could not initialize CUBLAS”;
return ;
}

I dont have any idea why the cublas initialization could fail!
the compiler likes my includes, no linker errors or anything suspicous.
I"m using Visual Studio 2005.

Is there perhaps a problem when combining cuda with cublas?

thx for your answers

Can you run the simpleCUBLAS example from the SDK?
The combination of CUDA, CUBLAS and CUFFT works.

yes it is working.

I also implemented a CG Algorithm for standard matrices which worked quite well (after some hours of debugging). So CUDA/CUBLAS should be installed correctly

Now i know what caused the problem.

If im compiling the cuda file in emulation mode it doesn’t work.
But I don’t know why.

I just dont compile with emulation mode anymore.

You need to link the emul version of the library (libcublasem.so), if you are compiling in emulation mode.

From the programming guide (Pag. 34, 4.5.2.7):

All code for an application, including any libraries used,
must be compiled consistently either for device emulation
or for device execution. Linking code compiled for device
emulation with code compiled for device execution causes
the following runtime error to be returned upon initialization:
cudaErrorMixedDeviceExecution.

I had the same problem, and solved getting off the cublas.lib from the linker, leaving only cublasemu.lib