Mixed execution mode and emulation mode error :device emulation mode and device

After a week of frustration I finally have my error…

After the kernel run I check for errors and get this error

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

Now is my question how I can eliminate this error. It looks like I’m compiling one part of the code with -deviceemu and the other part without or what?

But when I compile my code I compile all me .cu with nvcc -deviceemu as far as I can see.

Does anyone have an idea of what is going wrong?

some background information can be found here:

printf() not working in static library?

Ok, this might be sort of the same problem I am having.

Try to do (under linux) ‘ldd the_executable_or_library’
It lists all the dependencies.
In these dependencies, check that you require, for example, libcufftemu.so.1.1 instead of libcufft.so.1.1.
I still do not know how to compile it with devece_emulation dependencies but hope it helps.
Can anyone else put some light into the matter, please?

Further testing led to two possibilities:

  1. The library that is failing is: -lcudart. Since there is no -lcudartemu version (libcudartemu.so) the emulation mode fails.
  2. The nvcc does not like the other dependencies I include, which have only been compiled with gcc.

I would appreciate if anyone could report a similar execution error, or some information regarding the compilation in emulation mode.

You have to compile with “-deviceemu” option.

With Visual Studio (installed Wizard: http://forums.nvidia.com/index.php?showtopic=65111) you just have to right-click on project -> Properties -> CUDA -> CUDA-Specific -> Emulation "Yes(-deviceemu).

Have fun :biggrin:

I have turned emulation on. But I still got the same error. I am working on Vista64 and Visual Studio 2005.

Could anyone post the solution here?

It’s a long time for me ago that I did something with this. But make sure that all the libraries you are using are are compiled in device emulation. I have to say that I never programmed on Vista 64 nor Visual Studio with CUDA.

But good luck with it and let us know your findings

Thanks,

Jordy

Hi,

I am getting the same error at the very first cudaMalloc() call of my program: “device emulation mode and device execution mode cannot be mixed”.

I am using CUDA (2.2) Build Rule v.2.1.1 under Visual Studio 2008 (Vista 64).

Here is the command generated by the rule : “C:\CUDA\bin\nvcc.exe” -arch sm_13 -ccbin “C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin” -deviceemu -D_DEVICEEMU -Xcompiler "/EHsc /W3 /nologo /O2 /Zi /MTd " -maxrregcount=32 --compile -o “x64\Debug\myfile.cu.obj” “c:\mypath\myfile.cu”

Am I missing something here? I am pretty sure the emulation mode worked on this project at least once before.

I would be very grateful for any idea or advice.

Hi,

I also had this behavior. On one project it was working, on the other it didn’t. Finally, I recognized that I was using the compiler flags [font=“Courier New”]-g -G[/font] and [font=“Courier New”]–device-emulation[/font] at the same time (see below):

nvcc '--host-compilation=c++' -g -G --device-emulation ...

After removing [font=“Courier New”]-g -G[/font], everything worked fine for me.

nvcc '--host-compilation=c++' --device-emulation ...

Apparently, it seems that it is not possible to compile the source code for debugging purposes and device emulation at the same time.

I hope it helps!

Hello, can you give me some information that how did you solve this problem finally. Thank you. I am also frustrated by this now.

Hello, can you give me some information that how did you solve this problem finally. Thank you. I am also frustrated by this now.