user5090433
user5090433

Reputation: 163

is it possible to develop a cuda program in a virtual machine that has a ubuntu installed

I saw a video where a guy compiled one of his cuda program in a virtual box. Can anyone tell me how to do that?

Please go to 01:09:00 in that video to see he compiled the program in virgualbox .

PS: I have a gtx 970 card and the other graphic card installed on my workstation, but I don't want to install a real Ubuntu on it, I just want to using a VM to test the cuda world.

Upvotes: 12

Views: 42235

Answers (2)

Stéphane
Stéphane

Reputation: 20340

In a VirtualBox VM running Ubuntu 18.04, I installed the NVIDIA CUDA compiler and dev header files with the following:

sudo apt-get install nvidia-cuda-toolkit nvidia-cuda-dev libcupti-dev

This gives me:

> nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2017 NVIDIA Corporation
Built on Fri_Nov__3_21:07:56_CDT_2017
Cuda compilation tools, release 9.1, V9.1.85

Upvotes: 2

Robert Crovella
Robert Crovella

Reputation: 151849

Yes, it's possible.

The presenter in the video is using an Amazon EC2 cloud GPU instance.

In general, many types of VM (virtual machine) offerings can host a linux OS, upon which the CUDA toolkit could be loaded and codes compiled that way.

There is a difference between compiling a code and running a CUDA code, however. Running a CUDA code usually requires a CUDA GPU be present/available. This can be done using some types of VMs/hypervisors, but not every VM hypervisor supports the ability to place a physical GPU device into a VM (which is required, currently, to be able to run a CUDA code in a VM).

In general, to provide a GPU within a VM suitable for CUDA usage (currently) it is necessary for the VM/hypervisor to support some sort of PCI Passthrough capability.

Providing a full step-by-step tutorial would depend on the choice of specific hypervisor and is beyond the scope of an answer I can provide here.

Upvotes: 12

Related Questions