CUDA / OpenCL within a Virtual Machine / Hypervisor

29,729

Solution 1

NVIDIA announced GPU virtualization on the new Kepler cards this summer at GTC.

http://www.nvidia.com/object/vgx-boards.html

http://www.gputechconf.com/page/home.html

They not only announced it, they demonstrated it live

Solution 2

You can use Xen VGA passthrough to have full access and control over your graphic card inside a VM. You can find more information about this here: http://vfio.blogspot.com/ (look for VFIO GPU How To series parts 1-5).

I did it a few times, it's not very easy to setup, but it gives very good results (almost native). Here is a video of an experimentation I made that shows a dual VGA passthrough using Xen: http://www.youtube.com/watch?v=Gtmwnx-k2qg

I haven't tested OpenCL or CUDA, but I'm pretty sure it would work.

Solution 3

VirtualBox has PCI-passthrough, which allows you to use CUDA or OpenCL inside a Virtual Machine.

Share:
29,729

Related videos on Youtube

Bolster
Author by

Bolster

I'm a PhD student of Electronics & Software Engineering at Queen's University Belfast's Institute of Electronics, Comminucations, and Information Technology (ECIT). I want to get more involved in FOSS (as I've been using FOSS for years now). I try to document my experiments and experiences on my blog so check it out. Also an active founder of QUESTS (Queen's University, Engineering, Science, and Technology Society) and Farset Labs in Belfast, Northern Ireland

Updated on July 09, 2022

Comments

  • Bolster
    Bolster almost 2 years

    Anyone know of any virtualisation solutions that either allow CUDA/OpenCL access directly or implement CUDA/OpenCL abstraction.

    UPDATE: Thank you those who commented. While classical 'desktop' virtualization would be nice, I suspect the likes of Xen would be closer to the mark.

    • Martin Beckett
      Martin Beckett over 13 years
      Very much doubt it - even virtualbox which does have openGL hardware acceleration doesn't
    • user57368
      user57368 over 13 years
      This isn't possible yet, but will be eventually: in November 2008, VMWare bought Tungsten Graphics, the leading corporate developer of open-source 3d drivers and related stuff, such as the cross-platform Gallium driver infrastructure. Since then, they've started work on an OpenCL state tracker for gallium, and released a gallium back-end for their virtual GPU. It will be a while before the whole stack is production-ready, but most of the required pieces have already been started and are under active development.
    • Bolster
      Bolster about 13 years
      Leaving this question open as it might change.
    • James
      James over 12 years
      You might want to clarify, although it's pretty obvious, that you are interested CUDA/OpenCL on the GPU via virtualization. Today, you can use the OpenCL CPU compute device in a VM.
  • talonmies
    talonmies about 13 years
    CUDA certainly doesn't work with Xen at the moment.
  • alarouche
    alarouche about 13 years
    Just tested the "Design Garage" demo from NVIDIA featuring CUDA with the setup mentioned above and it works fine.
  • talonmies
    talonmies about 13 years
    Which distro is this with? None of the Redhat release Xen kernels works with CUDA.
  • alarouche
    alarouche about 13 years
    It's a Ubuntu 10.10 Dom0 kernel with Xen 4.1 compiled from sources. As I said in my answer, it's not straightforward to get VGA passthrough working.
  • Bolster
    Bolster about 13 years
    And this is why questions get left :D When I get back and can test this out I'll mark as answered. @Talonmies, I'd also be interested in your findings this.
  • user1111929
    user1111929 about 12 years
    So @Bolster have you tested it? Nearly a year has passed and it's still not been confirmed?
  • Bolster
    Bolster almost 12 years
    Glad to see that over a year on, I can finally look forward to this! I'll count that as an answer.
  • fche
    fche about 11 years
    Any recent work on this project?
  • John Thompson
    John Thompson almost 11 years
    Does it work with SLI? Can I SLI two cards together at the hypervisor level so that a VM sees one card?
  • steve cook
    steve cook over 10 years
    Only on Linux hosts though
  • steve cook
    steve cook over 10 years
    But 18 months later, still no sign of this on consumer cards.
  • steve cook
    steve cook about 10 years
    Looks like a dead project...
  • Sergei Krivonos
    Sergei Krivonos over 6 years
    Supports GPU OpenCL?
  • Arockia
    Arockia almost 4 years
    I attempted to enable pci-passthrough using vboxmanage modifyvm command. I am getting "VBoxManage: error: Unknown option: --pciattach" error. any idea?
  • inf3rno
    inf3rno over 3 years
    @Arockia I guess that the nvidia driver notices that it is running on a VM and raises an error. Some hypervisors can fool it to think it runs on normal hardware, not sure if VirtualBox has this kind of feature, probably not. As of the error you are trying to do something that is not supported by your VirtualBox. Not sure if this PCI attach is version dependent, but I would check it if I were you.