How To Use A GPU In VirtualBox

If you are someone who needs to use multiple different operating systems (OS) for work, or certain proprietary software programs which span multiple distinct platforms, there is a solution for … Read more

Taylor Bell

Taylor Bell

Published on Jul 03, 2024

How To Use A GPU In VirtualBox

If you are someone who needs to use multiple different operating systems (OS) for work, or certain proprietary software programs which span multiple distinct platforms, there is a solution for you. An easy way around this, without buying multiple devices, is to set up a virtual machine (VM) on your PC or laptop so that you can easily emulate other operating systems.

If you are frequently juggling between multiple operating systems on your computer, using a VM software like VirtualBox is helpful, although your powerful GPU won’t be able to perform as well in that context. That’s largely due to a glaring lack of GPU support on VirtualBox, even to this day. You need to jump through some hoops to use your GPU to its fullest while working in VirtualBox.

Two Mac desktop screens on a MacBook Air and Apple TV.

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 start, let’s clear the air about the current GPU support on VirtualBox. When you add a guest OS and run it on your machine, VirtualBox creates a virtual GPU to handle all graphical tasks. This is essentially a virtual generic graphics adapter that then hands off any calls to the host system and is how most type 2 hypervisors work. This happens regardless of whether your system has a dedicated GPU installed or not.

VirtualBox in general does not support GPU pass-through, but there are some things that you can do to improve the performance of VirtualBox in graphics tasks, but it’ll never directly use the GPU in your computer. Type 1 hypervisors are capable of that, such as VMware ESXi or KVM.

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

The main culprit here is VirtualBox’s lackluster support for GPU hardware acceleration. By default, VirtualBox can dedicate a maximum of only 128MB of video memory to your guest OS, which was fine in 2005 but isn’t enough for the current workflow. Its support ends at DirectX 9, which basically puts most modern applications that use 3D graphics out of commission. In this guide, we will share tips to improve your experience on whatever OS you install using VirtualBox.

Installing Ubuntu in Virtual box

Related

How to install Ubuntu in VirtualBox

You don’t need a dedicated laptop or desktop to run Ubuntu, you can run it in a virtual machine through Virtualbox instead.

Increase video RAM to 256MB and enable 3D acceleration

You need to tweak VirtualBox settings to have a smooth guest OS experience. VirtualBox dedicates only 128MB of video RAM to your virtual machine by default. We need to increase that, and while we’re at it, enable 3D acceleration, both of which will improve the performance of the guest OS.

  1. On the VirtualBox homepage, click on Settings.
  2. Click on Display. Use a slider to increase the Video memory to the highest setting, and click the checkbox at the bottom to enable 3D acceleration.
  3. Search for the Command Prompt from your Start Menu and Open as administrator. Then click Yes on the administrator prompt.
  4. Enter two commands to bump up the default video memory of VirtualBox to 256MB. For the first, simply paste this command into the Command Prompt and press Enter.
    cd "C:Program FilesOracleVirtualbox"
  1. Enter the Name of your virtual machine. If you don’t remember it, the easiest way to do it is to go into the General tab of VirtualBox’s settings and find the name there.
  2. With the VirtualBox’s directory selected in Command Promptenter the following command:
    vboxmanage modifyvm "Ubuntu" --vram 256

    Paste the name of your virtual machine inside the quotation marks, and press enter.

  3. Increase the video memory limit of 256MB from the Video settings menu in VirtualBox.
  4. Lastly, you will need to enable 3D acceleration. Restart the virtual machine to see better performance and higher utilization of your GPU.
    virtualbox video memory increased to 256mb and 3d acceleration enabled

Use a dedicated GPU instead of the integrated GPU

If you use a laptop or a desktop processor with an integrated GPU, you’ll want to make sure the graphical workload of VirtualBox is on your dedicated GPU. In order to ensure this, you’ll need to first shut down your virtual machine if it’s running, and close VirtualBox as well. Then you can follow the steps below within your main OS.

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 the Start menu or by pressing the Win + I key.
  2. Go to the System menu and open Display.
  3. Scroll to Graphics settings. Click on it.
  4. Keep the Desktop app selected in the dropdown menu and click on browse.
  1. Go into the directory where you installed VirtualBox and select VirtualBox.exe. Add it.
  2. Click Options and select the preferred graphics processor for this application. Pick a High-performance dedicated GPU and click on Save.
  3. Restart your virtual machine, and your guest OS will start using your dedicated GPU.
    virtualbox application selected and high performance nvidia gpu selected

Virtual machines with better GPU support

VirtualBox has its pros, but the painfully lacking GPU support is a dealbreaker for many. Another great option if you are using a Windows device is to use Microsoft’s Hyper-V. There are also some great paid virtual machine programs like VMware Fusion for even more features, excellent GPU support, and better stability.

Partager cet article

Inscrivez-vous à notre newsletter