Skip to content
Advertisement

How can I write CUDA in Visual Studio on Windows and deploy it to Linux?

I’m assisting a professor in setting up a lab for a class in parallel programming. The process will be the following:

A student logs into a virtual machine running Windows 7. This machine has no GPUs available. It has version 7.5 of the CUDA toolkit installed along with Visual Studio 2013. Students are supposed to use Visual Studio to write their CUDA programs/projects.

To test/run these projects, students have remote access to a fairly high-end machine. I don’t have physical access to it, but from what I can tell using the command line, it has four NVIDIA Tesla M40s. Students have remote access to this machine via SSH. The issue, though, is that this machine is running Linux (Ubuntu 14.04.5). I’m trying to figure out how to deploy what students write in Visual Studio on Windows to the Linux box with the GPUs. I have limited experience in C, C++, and CUDA. I can work my way around a make file, but specific instructions on this topic (if it’s part of the solution) would be appreciated.

I have read this article—Creating CUDA Projects for Linux—which details how to get NVIDIA’s sample projects running, but I’m not sure if I can adapt this to work in the given situation.

I’m looking for a simple way for students to write assignments in CUDA, but they also need to be able to run what they write. The reason that this professor and I prefer Visual Studio are:

  • It’s something many students in this class are familiar with

  • It handles project architecture fairly well

  • It offers students a GUI which can help reduce the learning curve (students can focus on CUDA instead of terminal, gcc, etc.—these things are undeniably incredibly useful, but they’re not the focus of the class)

If the test machine were running Windows, then students would be able to simply transfer the contents of the debug or release folder for their solutions in Visual Studio (on the development VM) to the test machine and then run the executable. Since there are two different operating systems in play, I don’t imagine it will work like this. I know that writing code on Windows and deploying on Linux won’t be quite as easy, but I’m hoping there’s a feasible solution.

Reconfiguring the setup and having students develop directly on the test machine or creating a Linux VM for development is doable, but should be avoided if at all possible. Reconfiguration would require involving the systems admin team and would delay the process of getting students writing code.

I have researched this and I’ve come across these questions, but they don’t quite apply to this specific case:

How to write programs in C# .NET, to run them on Linux/Wine/Mono?

How should I develop CUDA on OSX and the deploy test on Linux

Advertisement

Answer

The direct answer to the question is that it is not really practical to try to take a VS solution/project and reconstruct it in linux. It may be possible, but I wouldn’t put that burden on students trying to learn GPU programming.

An alternative would be to have your students use an X-forwarding SSH client such as Mobaxterm or else a remoting solution like TightVNC from the windows box (VM) to the linux box where the GPUs are. There are some nuanced differences between these two approaches. I believe the X-forwarded SSH client approach will have somewhat lighter network load and does not actually require an X-desktop to be running on the target, whereas TightVNC is an actual remote desktop solution. Therefore the user experience may be somewhat different for these two approaches, however if all the machines in question (windows VMs, linux GPU box(es)) have 100Mb or faster networking between them, and you’re only running a few clients at a time, I think it may not matter much.

Either solution will probably work best if you establish individual user accounts on the linux box for each student/client.

And since the students will be sharing the GPU resources, if multiple students are trying to run projects simultaneously, there could be issues, but probably not a problem for introductory level programming work.

Once they have made a connection, the students can then launch nsight to run the linux-based GUI IDE (nsight Eclipse Edition) to build CUDA projects, and run/debug/profile them.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement