OpenCL / CUDA support in guests?

This is for discussing general topics about how to use VirtualBox.
Post Reply
kebabbert
Volunteer
Posts: 321
Joined: 31. May 2008, 10:00
Primary OS: OpenSolaris 11
VBox Version: OSE other
Guest OSses: WinXP, RedHat, Ubuntu

OpenCL / CUDA support in guests?

Post by kebabbert »

How difficult would it be to add OpenCL / CUDA support in guests? And how can I request it?

I use Solaris 11 Express as host, and there are no OpenCL / CUDA available for S-11x. I would like to get that support in Window or Linux guests.
squall leonhart
Posts: 312
Joined: 21. Apr 2010, 10:39
Primary OS: MS Windows 7
VBox Version: PUEL
Guest OSses: Windows XP, 8, 10, Android x86

Re: OpenCL / CUDA support in guests?

Post by squall leonhart »

gpu CL,.... next to impossible at this point.
CPU CL, should be fine.

CUDA, will never happen.
kebabbert
Volunteer
Posts: 321
Joined: 31. May 2008, 10:00
Primary OS: OpenSolaris 11
VBox Version: OSE other
Guest OSses: WinXP, RedHat, Ubuntu

Re: OpenCL / CUDA support in guests?

Post by kebabbert »

CPU CL? What is that? Do you mean I can run OpenCL on the cpu? And when I have debugged my code in a guest, I startup a Linux or Windows machine and run OpenCL on the GPU?
squall leonhart
Posts: 312
Joined: 21. Apr 2010, 10:39
Primary OS: MS Windows 7
VBox Version: PUEL
Guest OSses: Windows XP, 8, 10, Android x86

Re: OpenCL / CUDA support in guests?

Post by squall leonhart »

Yes, both intel and amd have OpenCL sdk's available for their CPU's.

http://developer.amd.com/gpu/AMDAPPSDK/ ... fault.aspx
http://software.intel.com/en-us/article ... pencl-sdk/

im not to sure on the whole using the cpu during the dev and debugging of a GPU CL program, but it shouldn't be impossible.
kebabbert
Volunteer
Posts: 321
Joined: 31. May 2008, 10:00
Primary OS: OpenSolaris 11
VBox Version: OSE other
Guest OSses: WinXP, RedHat, Ubuntu

Re: OpenCL / CUDA support in guests?

Post by kebabbert »

Just to confirm: So, I could develop my source code in a Windows guest? The host is Solaris Express. Then, when everything is working, I could switch to a OpenCL GPU and run the code?
rjzak
Posts: 7
Joined: 16. Dec 2008, 16:24
Primary OS: Ubuntu other
VBox Version: PUEL
Guest OSses: Ubuntu, Windows, BSD

Re: OpenCL / CUDA support in guests?

Post by rjzak »

kebabbert wrote:Just to confirm: So, I could develop my source code in a Windows guest? The host is Solaris Express. Then, when everything is working, I could switch to a OpenCL GPU and run the code?
Theoretically, yes, as long as the system you would be using has the libraries installed. This is because the basic idea of OpenCL is that it'll use whatever is available: CPU and/or GPU.

As for GPU/CUDA support, it should be possible for the VirtualBox developers to implement this. After all, Amazon's EC2 does virtualization with GPUs exposed: https://aws.amazon.com/ec2/#instance.
kebabbert
Volunteer
Posts: 321
Joined: 31. May 2008, 10:00
Primary OS: OpenSolaris 11
VBox Version: OSE other
Guest OSses: WinXP, RedHat, Ubuntu

Re: OpenCL / CUDA support in guests?

Post by kebabbert »

"Theoretically, yes"

Ok, has anyone tested it? To develop and debug in a guest OS, and when the program is complete I will reboot into Windows and run the program on the GPU?
kebabbert
Volunteer
Posts: 321
Joined: 31. May 2008, 10:00
Primary OS: OpenSolaris 11
VBox Version: OSE other
Guest OSses: WinXP, RedHat, Ubuntu

Re: OpenCL / CUDA support in guests?

Post by kebabbert »

Ok, it seems that NVIDIA Cuda allows to use Emulation mode even if you have no NVIDIA graphics card. This means that the CUDA program you wrote, will only run on the CPU. This is used when debugging CUDA code. The old way to use Emulation was to specify the compile flag "-deviceemu", but has now changed so you add a library or something similar.

So, it should be possible to install Visual Studio and Nvidia CUDA SDK in Windows in VirtualBox and compile and run the source code on the CPU. And when the source code is debugged, you just stop using the Emulation mode (add another library and recompile) and then move the binary file to a Nvidia graphics card equipped computer. Myself, I will just reboot into Win7 and run the binary from there.
denka
Posts: 2
Joined: 3. Feb 2009, 09:00

Re: OpenCL / CUDA support in guests?

Post by denka »

Did anybody try this? I'm also interested in doing some OpenCL work in a VM (where all my homebrew development happens, for convenience of having the toolchain). I think this topic becomes too important to ignore, with mainstream CPUs integrating GPU functionality.
martin_sch
Posts: 1
Joined: 2. Jan 2017, 14:40

Re: OpenCL / CUDA support in guests?

Post by martin_sch »

denka wrote:Did anybody try this? I'm also interested in doing some OpenCL work in a VM (where all my homebrew development happens, for convenience of having the toolchain). I think this topic becomes too important to ignore, with mainstream CPUs integrating GPU functionality.
Yes. I used to develop within my debian vbox guest on a Windows host (Intel CPU). I did not manage to get OpenCL working in my debian guest with my NVIDIA GPU, but with the Intel OpenCL sdk (opencl_runtime_16.1.1_x64_ubuntu_6.4.0.25.tgz <- already outdated but works fine for me) on my CPU.

Alternative:
Right now I'm developing on Windows 10 (c++/OpenCL) and do additional compiling/testing using WSL. OpenCL on Intel CPU works fine on WSL, it's more convenient than switching between host/guest while developing and almost everything I need for developing works (for example valgrind doesn't work).
For GPU tests I'm using my Windows host or grab an Amazon EC2-G2 instance.
Post Reply