# easy question - compiling CUDA code

**URL:** <https://forums.developer.nvidia.com/t/easy-question-compiling-cuda-code/3678>\
**Category:** CUDA Programming and Performance\
**Created:** [May 12, 2008, 1:44am UTC](https://forums.developer.nvidia.com/t/easy-question-compiling-cuda-code/3678 "2008-05-12T01:44:16Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![estra](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@estra](https://forums.developer.nvidia.com/u/estra)\
**Post date:** [May 12, 2008, 1:44am UTC](https://forums.developer.nvidia.com/t/easy-question-compiling-cuda-code/3678/1 "2008-05-12T01:44:16Z")

</div>

is it possible to compile CUDA code on a machine without a CUDA enabled card and just have the CPU do all the work?

---

<div class="post-metadata">

**Author:** ![Mu-Chi\_Sung](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Mu-Chi\_Sung](https://forums.developer.nvidia.com/u/Mu-Chi_Sung)\
**Post date:** [May 12, 2008, 5:36am UTC](https://forums.developer.nvidia.com/t/easy-question-compiling-cuda-code/3678/2 "2008-05-12T05:36:05Z")

</div>

> [@](#):
>
> is it possible to compile CUDA code on a machine without a CUDA enabled card and just have the CPU do all the work?
> 
> [snapback]375767[/snapback]

Yes, that’s the device emulation mode

---

<div class="post-metadata">

**Author:** ![estra](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@estra](https://forums.developer.nvidia.com/u/estra)\
**Post date:** [May 12, 2008, 5:54am UTC](https://forums.developer.nvidia.com/t/easy-question-compiling-cuda-code/3678/3 "2008-05-12T05:54:02Z")

</div>

> [@](#):
>
> Yes, that’s the device emulation mode
> 
> [snapback]375829[/snapback]

im using winXP with visual studio, **how do i get the device emulation mode to work?** Currently when i compile it complains about not having a device

---

<div class="post-metadata">

**Author:** ![Mu-Chi\_Sung](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Mu-Chi\_Sung](https://forums.developer.nvidia.com/u/Mu-Chi_Sung)\
**Post date:** [May 12, 2008, 6:00am UTC](https://forums.developer.nvidia.com/t/easy-question-compiling-cuda-code/3678/4 "2008-05-12T06:00:25Z")

</div>

> [@](#):
>
> im using winXP with visual studio, **how do i get the device emulation mode to work?** Currently when i compile it complains about not having a device
> 
> [snapback]375831[/snapback]

Oops, maybe I am wrong. To run device emulation you need to load cudart.dll, which is included in the CUDA display driver,…so if you dont have the card, you can not install the driver I guess…then you won’t be able to run any cuda program. However I suspect I can force to install and load cudart under Linux without gpu installed…

(Sorry it has been a while that I work with CUDA on Windows…I shifted to Linux long time ago)

Any one tried it before?

---

<div class="post-metadata">

**Author:** ![Sarnath](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/sarnath/32/9742_2.png) [@Sarnath](https://forums.developer.nvidia.com/u/Sarnath)\
**Post date:** [May 12, 2008, 7:53am UTC](https://forums.developer.nvidia.com/t/easy-question-compiling-cuda-code/3678/5 "2008-05-12T07:53:38Z")

</div>

YOu can run “Device emulation” on a box without gpu… Thats y device emulation is in place,.

YOu need to add “–deviceemu” compiler option while compiling…

I hope you have first installed CUDA on your machine where you want to compile. YOu need to the driver and SDK installed first. It does NOT matter if you dont have the card. So, go ahead, install driver and SDK and then compile code.

I hope you know how to compile CUDA code (.cu file, custom build rule using nvcc etc.)

Best Regards,  
Kandi

---

<div class="post-metadata">

**Author:** ![DenisR](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@DenisR](https://forums.developer.nvidia.com/u/DenisR)\
**Post date:** [May 12, 2008, 8:12am UTC](https://forums.developer.nvidia.com/t/easy-question-compiling-cuda-code/3678/6 "2008-05-12T08:12:09Z")

</div>

MCUDA also looks interesting, but I am not sure you can download it anywhere yet.

---

<div class="post-metadata">

**Author:** ![Sarnath](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/sarnath/32/9742_2.png) [@Sarnath](https://forums.developer.nvidia.com/u/Sarnath)\
**Post date:** [May 12, 2008, 8:52am UTC](https://forums.developer.nvidia.com/t/easy-question-compiling-cuda-code/3678/7 "2008-05-12T08:52:22Z")

</div>

> [@](#):
>
> MCUDA also looks interesting, but I am not sure you can download it anywhere yet.
> 
> [snapback]375863[/snapback]

MCUDA???

---

<div class="post-metadata">

**Author:** ![DenisR](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@DenisR](https://forums.developer.nvidia.com/u/DenisR)\
**Post date:** [May 12, 2008, 8:54am UTC](https://forums.developer.nvidia.com/t/easy-question-compiling-cuda-code/3678/8 "2008-05-12T08:54:52Z")

</div>

[url=“[MCUDA - Google Search](http://www.google.com/search?q=MCUDA&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a)”][MCUDA - Google Search](http://www.google.com/search?q=MCUDA&ie=ut...lient=firefox-a%5B/url%5D)

---

<div class="post-metadata">

**Author:** ![seibert](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/seibert/32/520688_2.png) [@seibert](https://forums.developer.nvidia.com/u/seibert)\
**Post date:** [May 12, 2008, 1:46pm UTC](https://forums.developer.nvidia.com/t/easy-question-compiling-cuda-code/3678/9 "2008-05-12T13:46:09Z")

</div>

> [@](#):
>
> http://www.google.com/search?q=MCUDA&ie=ut…lient=firefox-a
> 
> [snapback]375877[/snapback]

It would be great if this research were integrated into the CUDA toolchain to generate binaries that worked on both CUDA and non-CUDA systems. Not having to hand-code a CPU-only path would be nice.

---

<div class="post-metadata">

**Author:** ![mfatica](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@mfatica](https://forums.developer.nvidia.com/u/mfatica)\
**Post date:** [May 12, 2008, 1:51pm UTC](https://forums.developer.nvidia.com/t/easy-question-compiling-cuda-code/3678/10 "2008-05-12T13:51:38Z")

</div>

We have a similar solution in the work.  
You will be able to recompile your CUDA code to multicore changing just a compiler flag.

---

<div class="post-metadata">

**Author:** ![seibert](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/seibert/32/520688_2.png) [@seibert](https://forums.developer.nvidia.com/u/seibert)\
**Post date:** [May 12, 2008, 2:03pm UTC](https://forums.developer.nvidia.com/t/easy-question-compiling-cuda-code/3678/11 "2008-05-12T14:03:19Z")

</div>

> [@](#):
>
> We have&nbsp; a similar solution in the work.
> 
> You will be able to recompile your CUDA code to multicore changing just a compiler flag.
> 
> [snapback]375949[/snapback]

Awesome! Some kind of runtime selection between the two code paths would be nice too, but a compile time selection is good enough for me.

---

<div class="post-metadata">

**Author:** ![MisterAnderson42](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@MisterAnderson42](https://forums.developer.nvidia.com/u/MisterAnderson42)\
**Post date:** [May 14, 2008, 2:35pm UTC](https://forums.developer.nvidia.com/t/easy-question-compiling-cuda-code/3678/12 "2008-05-14T14:35:18Z")

</div>

> [@](#):
>
> We have&nbsp; a similar solution in the work.
> 
> You will be able to recompile your CUDA code to multicore changing just a compiler flag.
> 
> [snapback]375949[/snapback]

**Very** nice. I’ve been wanting to add multicore support to HOOMD for a while, but didn’t really have the time to devote to it. Now, I’ll be getting it for free through CUDA :) CUDA is the best thing since homemade bread (sliced bread stinks :P ).

---

<div class="post-metadata">

**Author:** ![akift](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@akift](https://forums.developer.nvidia.com/u/akift)\
**Post date:** [May 20, 2008, 11:45am UTC](https://forums.developer.nvidia.com/t/easy-question-compiling-cuda-code/3678/13 "2008-05-20T11:45:23Z")

</div>

> [@](#):
>
> is it possible to compile CUDA code on a machine without a CUDA enabled card and just have the CPU do all the work?
> 
> [snapback]375767[/snapback]

Yes it is possible and you dont even have to install the driver. My windows laptop has ATI card and I just installed the toolkit and SDK for windows and thats it. Now i can compile emudebug and emurelease versions of the SDK examples. OpenGL examples has other issues which i m not interested in.

And for the MCUDA, I just printed it out for the way back home but abstract sounds good.And hearing NVIDIA has already a work for this, is just better.

---

<div class="post-metadata">

**Author:** ![Lsesma](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Lsesma](https://forums.developer.nvidia.com/u/Lsesma)\
**Post date:** [May 27, 2008, 10:53am UTC](https://forums.developer.nvidia.com/t/easy-question-compiling-cuda-code/3678/14 "2008-05-27T10:53:30Z")

</div>

> [@](#):
>
> Hi,
> 
> Iam new and IÂ´m trying to compile some code in CUDA and I get this error:
> 
> C:\CUDA\bin\nvcc.exe is not a valid Win32 application.
> 
> So I canÂ´t even get to compile anything. Does anyone know what can the problem be?
> 
> [snapback]379929[/snapback]
