Is there a virtual machine with direct access to CPU and GPU for gaming?

13,949

Solution 1

The short answer is: No.
The longer answer is: Not yet...

VBox's 3D support barely counts. It does provide 3D support but absolutely no performance. VMWare seems to perform a lot better (note the benchmark is on a Mac) and that might be playable. The downside here is a large pile of cash (I'm not sure what 3D support is like in their free offerings).

But if you want to take full advantage of your hardware for Windows-only games, there's only one solution and that's to boot into Windows. I'm afraid to say that's likely always going to be the case for that subset of games.

The only other near-acceptable solutions available:

  • Fight Wine (when it does work, it tends to work really well)
  • Buy a console.
  • Lobby the developer for a port.

There are all sorts of server technologies that may filter through in time:

  • Nvidia+Vmware are working on a multi-head virtualised gaming platform but I honestly don't expect this level of integration to be in consumers' hands for another decade, if not longer. Graphics manufacturers want us to buy dozens and dozens of cards and virtualising hurts that aim.

  • You could reverse it and have a Windows Server host VM and paravirt a Ubuntu desktop, with shared 3D but again, I'm not sure what the performance would be like. And it's a ton of cash to do legally. The desktop-host isn't as good at all.

  • Xen won't paravirt a Windows install, so there's no point looking there yet. It does have PCI and VGA passthrough modules but they're locked to one VM so you'd have to have a graphics card for each install. Urgh.


Note I'm really only talking about 3D graphics here because the rest are solved or nearly-solved problems. CPU virtualisation is mature with paravirtualisation and CPU extensions like Intel VT-x and AMD-V. Peripheral passthrough is fairly low bandwidth so is simple to share.

Graphics are lagging because sharing them in the way we're talking about is not a commercial necessity for manufacturers. It does seems to be going that way though (for high-end render farms and server-based workstation consolidation) so watch that space.

Solution 2

If both your hardware and your software support IOMMU (a.k.a. PCI passthrough, AMD-Vi and Intel VT-d), you can assign assign I/O devices (e.g., the graphics card) to VMs.

On the current versions of Ubuntu, you can use Xen, as long as both your motherboard and your CPU support IOMMU.

I'm currently using a Windows 7 VM with two AMD 7950 GPUs, and it works very well for gaming and Bitcoin/Litecoin mining.

Tutorials, etc.:

Note that you can use the GPU on in that VM is you pass it through.

Solution 3

Your windows VM mostly runs on emulated hardware. That hardware is usually relative simple.

Having said that:

  1. It is possible to emulate 3D functions. Performance is usually sub par, and sometimes it does not work as expected. (E.g. running Baldur's Gate 1 with 3D acceleration enabled in Vmware workstation 8 crashes my whole host. Not just the VM). This will improve over time for all VMs.
    In fact, vmware workstation 9 claims significant improvements, but I have not tested that version yet. I know 5.5 and 8 did not suffice.
  2. Instead of emulating you can directly access hardware from a VM. The keyword is is PCI[e] passthough. This is a feature usually used to pass though special cards, 10 Gbit NICs etc, but it should also work for graphics cards.. Note that will use a card only for the VM. With graphics cards this means using a second graphics card for the VM.
Share:
13,949

Related videos on Youtube

psylockeer
Author by

psylockeer

Updated on September 18, 2022

Comments

  • psylockeer
    psylockeer over 1 year

    Sorry for the long question.

    With the coming of Steam for Linux I may have been over optimistic and got rid of windows installation. The problem is that I have about 100 Steam games that are not (and may never be) ported to Linux. Anyway I got tired of dual boot, and Wine solutions (wineprefix and playonlinux) don't always work. So I was wondering if there is any solution to use a virtual machine (or something similar) with direct access to hardware spec in order to run windows games in it. (something like what Parallels do on mac). Re-installing windows is not a huge problem but I was hoping to avoid it as I would like use Ubuntu as my everyday OS together with more "difficult" distros..to learn more about Linux.

    Edit: Thanks for all your answers: I'll think about the solution you proposed. Honestly to this day I never heard of Xen, so I'll have to read about it...and maybe buy a new graphic card...and a new monitor. I think I'll end up re-installing windows on one of my drives...It's a pity though. thanks again.

    • Takkat
      Takkat about 11 years
      See this question on heavy limitations for being able to access the GPU from Virtual Box.
    • Chad Harrison
      Chad Harrison about 11 years
      @Takkat Did you ever get a chance to try the PCI pass-through? Did it work out well?
    • Takkat
      Takkat about 11 years
      @hydroparadise: no my hardwares do not support IOMMU. I guess it is not really easy to achieve, and you need 2 graphic cards.
  • psylockeer
    psylockeer about 11 years
    Virtualbox does indeed let you install windows, but as far as I know 3d gaming in it is not that easy to achieve.
  • WA2050
    WA2050 about 11 years
    Honestly, I have never tried that. I've always preferred dual booting with Windows just to play games. And it looks like that some games will work some will not so mostly it depends on which games you want to run
  • kernel
    kernel about 11 years
    I believe he won't be able to share a single GPU between VMs. However, if he has two video cards (especially if he has multiple monitors or a monitor with two suitable inputs), or he's fine with accessing GNU/Linux GUI solely over VNC, SPICE or alike, Xen's GPU passthrough seems to be a a way to go.
  • zBertok
    zBertok about 11 years
    @drdaeman: True. When passing though a GPU, it can be accessed only from that VM.
  • Chad Harrison
    Chad Harrison about 11 years
    As for wine, PlayOnLinux is definitely worth looking at... playonlinux.com/en
  • psylockeer
    psylockeer about 11 years
    @Oli your answer was very complete, thanks. Anyway, I saw that it is possible to mount an existing Windows installation into a virtual machine (after proper work). In that case would hardware acceleration be the same as palin virtualization?
  • Oli
    Oli about 11 years
    @psylockeer You mean mounting a physical drive (with a real install of Windows on it) inside a VM? That can be done in all the major virtualisation software but you might find Windows flips out. The last time I tried to change the hardware on a Windows install it flipped out and never made it further than a bluescreen. Hopefully MS have improved things since then. The access still isn't direct (AFAIK) as the VM client is still accessing the drive through Linux - it's just not on another filesystem too (if that makes any sense) - so don't expect a large performance boost.
  • Hennes
    Hennes about 11 years
    That 2 monitor thing is a good point. I never considered it since I lump PCI passthough to NICs, RAID cards and such. --- Note that most monitors have more than one signal input. E.g. DVI, DP, composite, S-Video and component... Not that switching the input of a monitors between two sources is all that great of an solution.
  • psylockeer
    psylockeer about 11 years
    thnks guys, sadly for the moment this solutionis out of my knowledge...and my pockets :-)