Question: i wrote a cuda program and i am testing it on ubuntu as a virtual machine. the reason for this is i have windows 7, i don't want to install ubuntu as a secondary operating system, and i need to use a linux operating system for testing.
my question is: will the virtual machine limit the gpu resources? So will my cuda code be faster if i run it under my primary operating system than running it on a virtual machine?

Answer: 
I faced a similar task once. What I ended up doing was installing Ubuntu on a 8GB thumb drive with persistent mode enabled. 

That gave me 4GB to install CUDA and everything else I needed.

Having a bootable USB stick around can be very useful. I recommend reading [this](https://wiki.ubuntu.com/LiveUsbPendrivePersistent).

Also, [this link](http://www.infosecramblings.com/backtrack/backtrack-4-usbpersistent-changesnessus/) has some very interesting material if you're looking for other distros.
Use [rCUDA](http://rcuda.net/) to add a virtual GPU to your VM.