Windows – Use NVidia GPU from VirtualBox

nvidia-graphics-cardoptimusvirtual machinevirtualboxwindows 7

How do I make the VirtualBox guest use the NVidia graphics?

Host setup:

  • Windows 7 x64

  • NVidia Optimus

  • In NVIDIA Control Panel, I explicitly selected High-performance NVIDIA processor
    for:

     C:\Program Files\oracle\VirtualBox\VirtualBox.exe
     C:\Program Files\Oracle\VirtualBox\VBoxSVC.exe
    
  • When VirtualBox is running, then the NVidia software does not list it as application
    that uses the NVidia GPU. Therefore, I assume that VirtualBox indeed does not use the
    Nvidia GPU.

Guest:

  • Windows 7 x64 (i.e. same as host)

  • Guest Additions installed

  • 3D acceleration enabled in VirtualBox settings: Display / Video / Enable 3D
    Acceleration

  • What Rhinoceros, an OpenGL capable application reports as video adapter:

    Humper
    Chromium
    OpenGL version: 2.1 Chromium 1.9
    Render version: 2.0
    Shading Language: 1.40 - Intel Build 9.17.10.3517
    Driver Date: NA
    Driver Version: NA
    Maximum Texture size: 8192 x 8192
    Z-Buffer depth: 32bits
    Maximum Viewport size: 8192 x 8192
    Total Video Memory: 64 MB
    

    To me it looks like the virtual machine does use 3D hardware acceleration of the host,
    but unfortunately the Intel one.

Best Answer

I realize a few years have passed but wanted to answer since this post shows up pretty high when you google for "virtualbox 3d multiple GPU". In the time that has passed, things have gotten a lot simpler and better.

People that stumble upon this thread will likely land here because they have a laptop or PC that has two GPU's, which is quite common these days -- especially on gaming laptops. The onboard Intel GPU is used for rendering windows and general applications, but applications that make use of GPU 3D functionality should do that via the higher performing Nvidia GPU.

Today, I was building an Ubuntu VM on my laptop to do some cross-platform development, and everything was fine except the guest VM was extremely slow, and there was no explanation for it because CPU, memory, disk were all showing low utilization.

It didn't take long to figure out it was video performance that was causing the problem. Launching applications, maximizing/minimizing windows -- anything that we take for granted in 2019 but needs 3D acceleration to work at any reasonable speed -- was using GPU 0.

It was easy to determine this because Windows 10 now has the ability to see GPU utilization using "task manager", then the "performance" tab. And I could see as I moved windows, maximized, minimized, that was being done through GPU on the host. That GPU on the host is the integrated Intel HD GPU, and I wanted to use the NVidia GTX-1050ti, which was GPU1.

After searching around I didn't really find anywhere where you could specify which GPU to use. But this thread, and some others, reminded me that on these kind of setups you have to go into the NVidia control panel, then "manage 3d settings", then the "Program Settings" tab.

You won't likely find "Virtualbox" in the list. But you can press the "Add" button, and add virtualbox.exe. You may have to drill down the drive/path where your virtualbox installation is. Once you have added it, in the settings below make sure that item 2. "Select the preferred graphics processor for this program" is set to the GPU that you want it to use, which in my case was "HIgh-performance NVIDIA processor".

Don't set it to auto, and certainly don't set it to integrated. Of course, you need the VM settings set with the 3D acceleration box ticked, and you need the guest additions installed on the host. But once you have set the host video 3d settings as described above, shutdown the guest VM, exit virtual box, and then re-launch virtualbox and the VM.

If you use task manager|performacne and look at the "virtualbox manager" process and watch what GPU gets used when you navigate the guest VM's UI, you should see it using the better GPU now. See the image pasted below.

All that said, don't expect to be able to run games in a guest VM. 3D acceleration pass thru still is not quite that far along. But you can expect to have a modern OS and UI in your guest, and have an acceptable experience. One would be able to play older games in the guest VM, like anything based on directX9. Unfortunately, as the ability to virtualize GPU eveolves, the 3d gaming technology evolves quicker.

Screenshot

Related Question