Compiling with --device-emulation option

Hello,

I am trying to compile a project including some CUDA code. Compile operation seems good, but when I run the binary, I get the following error:

CUDA error: device emulation mode and device execution mode cannot be mixed

When I look the links of the binary, I get the following:

$ ldd myapp

	linux-gate.so.1 =>  (0xb76fe000)

	libcudart.so.2 => /home/jerome/cuda/lib/libcudart.so.2 (0xb76b5000)

	libcublas.so.2 => /home/jerome/cuda/lib/libcublas.so.2 (0xb67de000)

	liblapack.so.3gf => /usr/lib/liblapack.so.3gf (0xb5fb8000)

	libblas.so.3gf => /usr/lib/libblas.so.3gf (0xb5f31000)

	libmpi_f90.so.0 => /usr/lib/libmpi_f90.so.0 (0xb5f2e000)

	libmpi_f77.so.0 => /usr/lib/libmpi_f77.so.0 (0xb5f00000)

	libmpi.so.0 => /usr/lib/libmpi.so.0 (0xb5e69000)

	libopen-rte.so.0 => /usr/lib/libopen-rte.so.0 (0xb5e27000)

	libopen-pal.so.0 => /usr/lib/libopen-pal.so.0 (0xb5dbf000)

	libdl.so.2 => /lib/i686/cmov/libdl.so.2 (0xb5dbb000)

	libnsl.so.1 => /lib/i686/cmov/libnsl.so.1 (0xb5da3000)

	libutil.so.1 => /lib/i686/cmov/libutil.so.1 (0xb5d9f000)

	libgfortran.so.3 => /usr/lib/libgfortran.so.3 (0xb5cda000)

	libm.so.6 => /lib/i686/cmov/libm.so.6 (0xb5cb4000)

	libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb5c97000)

	libpthread.so.0 => /lib/i686/cmov/libpthread.so.0 (0xb5c7e000)

	libc.so.6 => /lib/i686/cmov/libc.so.6 (0xb5b35000)

	libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0xb5a44000)

	librt.so.1 => /lib/i686/cmov/librt.so.1 (0xb5a3b000)

	/lib/ld-linux.so.2 (0xb76ff000)

I notice on line 2 that it is linked with libcublas.so.2 . It should be linked with libcublasemu.so.2, no? What more than compile --device-emulation should I do?

You have obviously linked it with -lcublas. Try linking it with -lcublasemu and see what happens.