How to use a GPU in VirtualBox

If your job requires you to use multiple different operating systems (OS) or certain proprietary software programs that span multiple different platforms, there is a solution for you. An easy way to get around this without having to buy multiple devices is to set up a virtual machine (VM) on your PC or laptop so you can easily emulate other operating systems.




If you often juggle between multiple operating systems on your computer, using VM software like VirtualBox is helpful, even if your powerful GPU may not perform as well in this context. This is mainly because VirtualBox does not yet offer GPU support. You'll have to overcome a few hurdles to get the most out of your GPU when working in VirtualBox, but keep in mind that it still won't be fully functional.

Related

How to install macOS in VirtualBox

You can run macOS in a dedicated sandbox

The sad state of GPU support on VirtualBox

Ubuntu opened in Virtualbox with Task Manager on the right


Before we begin, let's clarify something about the current GPU support on VirtualBox. When you add a guest operating system and run it on your computer, VirtualBox creates a virtual GPU that handles all graphical tasks. This is essentially a virtual generic graphics adapter that then forwards all calls to the host system. This is how most Type 2 hypervisors work. This happens regardless of whether you have a dedicated GPU installed on your system or not.

VirtualBox generally doesn't support GPU passthrough, but there are some things you can do to improve VirtualBox's performance on graphics tasks, but that will never be the case direct Use the GPU in your computer. Type 1 hypervisors are capable of this, for example VMware ESXi or KVM.


Let's take our PC system as an example. It runs on a first-generation Ryzen 5 1400 CPU and an Nvidia GTX 1060 to handle heavy workloads. When we ran Ubuntu OS, we quickly noticed some choppiness and an overall subpar experience. But the good news is that there are ways to improve this without having to switch to different VM software entirely.

The main reason for this is VirtualBox's lack of support for GPU hardware acceleration. By default, VirtualBox can only allocate a maximum of 128MB of video memory to your guest operating system, which was fine in 2005 but is not enough for current workflow. Support ends at DirectX 9, which essentially disables most modern applications that use 3D graphics. In this guide, we'll provide tips on how to improve your experience on any operating system you install with VirtualBox.


Related

How to install Ubuntu in VirtualBox

You don't need a dedicated laptop or desktop to run Ubuntu, but can instead run it in a virtual machine via Virtualbox.

Increase video RAM to 256MB and enable 3D acceleration

You need to adjust VirtualBox settings to ensure a smooth guest OS experience. By default, VirtualBox only provides your virtual machine with 128MB of video RAM. We need to increase this while also enabling 3D acceleration, both of which will improve guest OS performance.

  1. On the VirtualBox homepage, click Settings.
  2. Click on Advertisement. Use a slider to increase the Video storage Set to the highest setting and click the checkbox below to enable 3D acceleration.
  3. Look for that Prompt from your start menu and Open as administrator. Then click Yes on the administrator command prompt.
  4. Enter two commands to increase VirtualBox's default video memory to 256MB. First, just paste this command into the Prompt and press Input.
    cd "C:\Program Files\Oracle\Virtualbox"

  1. Enter that name your virtual machine. If you don't remember it, the easiest way to do this is to go to the General tab in VirtualBox Settings and find the name there.
  2. With the VirtualBox directory selected in Promptenter the following command:
    vboxmanage modifyvm "Ubuntu" --vram 256

    Paste the name of your virtual machine in the quotation marks and press Enter.

  3. Increase the video storage limit by 256MB from the Video settings Menu in VirtualBox.
  4. Lastly, you need to activate it 3D acceleration. Restart the virtual machine for better performance and higher utilization of your GPU.


Use a dedicated GPU instead of the integrated GPU

If you are using a laptop or desktop processor with an integrated GPU, you should ensure that VirtualBox's graphical workload is on your dedicated GPU. To ensure this, you must first shut it down Your virtual machine, if it is running, and Close VirtualBox as well as. Then you can follow the steps below in your main operating system.

You can skip this part if your PC doesn't have an i-GPU. We'll use Nvidia as an example here, but the process for AMD GPUs is similar.

  1. Open Windows Settings by searching in start Menu or by pressing the button Victory + me Key.
  2. Go to system Call up and open the menu Advertisement.
  3. Scroll to Graphics settings. Click on it.
  4. Keep those Desktop app Select from the drop-down menu and click browse.

  1. Go to the directory where you installed VirtualBox and select VirtualBox.exe. Add it.
  2. Click Options and select the preferred graphics processor for this application. Choose one Powerful dedicated GPU and click Save.
  3. Restart your virtual machine and your guest operating system will start using your dedicated GPU.


Virtual machines with better GPU support

VirtualBox has its advantages, but the sore lack of GPU support is an issue for many. Another great option if you use a Windows device is to use Microsoft Hyper-V. There are also some great paid virtual machine programs like VMware Fusion for even more features, great GPU support, and better stability.

Leave a Comment