Running CUDA on a virtual machine without a physical NVidia GPU card - cuda

Is it possible to run a CUDA program on a virtual machine without having a physical NVidia GPU card on the host machine?
PCIe passthrough is only viable if the host machine has an NVidia card and that's not available.
One possible option to run CUDA programs without a GPU installed is to use an emulator/simulator (ex: http://gpgpu-sim.org/ ) but these simulators are usually limited.
I would appreciate a clear answer on that matter.
Thanks!

You can't run any modern version of CUDA (e.g. 6.0 or newer) unless you have actual GPU hardware available on the machine or virtual machine.
The various simulators and other methods all depend on very old versions of CUDA.

Related

Running CUDA programs on Quadro K620m

I have laptop which has Quadro K620m GPU. I am trying to learn CUDA programming and downloaded the network installer from NVIDIA site.
During CUDA SDK installation, just when its checking the hardware of the machine, it displays
Do you want to Continue?
This graphics driver could not find compatible graphics hardware. You may continue installation, but you will not be able to run CUDA applications.
Any thoughts why this could be happening? In my computer's device manager, I can see NVIDIA Quadro K620m in the display adapter listing.
Thank you.
This is normal, when the driver packaged in the CUDA installer is "older" than your GPU.
You should retain your current GPU driver, and go ahead with the CUDA toolkit installation, but de-select the option to install the GPU driver.
Your existing driver should work fine.

Can I compile a cuda program without having a cuda device

Is it possible to compile a CUDA program without having a CUDA capable device on the same node, using only NVIDIA CUDA Toolkit...?
The answer to your question is YES.
The nvcc compiler driver is not related to the physical presence of a device, so you can compile CUDA codes even without a CUDA capable GPU. Be warned however that, as remarked by Robert Crovella, the CUDA driver library libcuda.so (cuda.lib for Windows) comes with the NVIDIA driver and not with the CUDA toolkit installer. This means that codes requiring driver APIs (whose entry points are prefixed with cu, see Appendix H of the CUDA C Programming Guide) will need a forced installation of a "recent" driver without the presence of an NVIDIA GPU, running the driver installer separately with the --help command line switch.
Following the same rationale, you can compile CUDA codes for an architecture when your node hosts a GPU of a different architecture. For example, you can compile a code for a GeForce GT 540M (compute capability 2.1) on a machine hosting a GT 210 (compute capability 1.2).
Of course, in both the cases (no GPU or GPU with different architecture), you will not be able to successfully run the code.
For the early versions of CUDA, it was possible to compile the code under an emulation modality and run the compiled code on a CPU, but device emulation is since some time deprecated. If you don't have a CUDA capable device, but want to run CUDA codes you can try using gpuocelot (but I don't have any experience with that).

How cudaMalloc is internally implemented under Ubuntu Linux?

I would like to know how the allocation of a memory space in CUDA is implemented under Ubuntu Linux. In other words, how cudaMalloc() works internally under Ubuntu Linux? What are the system calls used for this function?
CUDA is proprietary. It's likely that CUDA driver implementation is the same or similar to OpenCL.
But while OpenCL specification is open the implementation is not necessary and NVIDIA OpenCL driver isn’t open .
It's possible that the implementation is as simple as the driver submitting a malloc command completely handled on the hardware side with the kernel driver communicating with the system to achieve unified virtual addressing and to determine what memory resides in VRAM. Probably the technical part at the software side is to avoid the allocation or defer it.
Looking into pocl can give you some idea how things can look like. NVIDIA implementation can be very different though.

Can you Program/Test CUDA in a Virtual Machine?

I ask this as a programming and environment question. Can you test/program CUDA within a virtual machine accessing the physical GPU card?
I am buying a new (really nice system) to, in part, experiment with basic CUDA programming. The processor will be an Intel i7-4770 which supports VT-d (direct IO pass-through) OR a i7-4770K which does not. Will the VT-d support allow access to the GPU card from the VMs? (I have looked at Intel, motherboard mfg. sites, and docs on VMs but did not see an answer to this question.)
I plan to run Linux as my base operating system on the new development box with virtual machines (probably via QEMU/KVM) to test the software in other environments such as Windows and Mac OS. I other words, I would do the major development on the Linux box and then need to test on a virtual machine running on the same box.
But, will the VM OSs be able to access the GPU card for testing/development?
[First asked July 2013]
It depends on what NVIDIA card you're using. See for example: (this is in regards to Xen)
http://wiki.xen.org/wiki/XenVGAPassthroughTestedAdapters#Nvidia_display_adapters
The short answer is you probably would need to rely on modifying a consumer card as they link above as 'Australian crazy guy'.

Support for local single GPU debugging

Which combinations of GPU hardware, operating systems and NVIDIA software / drivers support local, single GPU debugging?
Single-GPU debugging works:
On Windows using Nsight Visual Studio edition.
On Mac or Linux when running in console mode (e.g. without windowing environments)
Also note that both GPUs do not need to be CUDA GPUs - e.g. we have tested several Linux setups that have Intel and NVIDIA GPUs with Intel driving the OS UI.