# How to avoid slowdown with 25-30 students running simple GPU kernels on 4 GeForce GTX 650 Ti s?

So I'm teaching crash-course in CUDA that teaches students how to write good GPU code (CUDA 7.5 in this case). They kernels they will be running will do matrix multiply on 2048x2048 floating point matrices, some kernels involving multiple blocks and shared memory.

The students will be ssh-ing into servers that have the GPUs where they will compile and run their programmes.

I haven't a clue on how feasible this is and the only step I can imagine taking to prevent slowdown is to assign groups of students to different GPUs by telling them what value to pass cudaSetDevice().

Edit for posterities' sake: I ended up not taking any precautions and the lab ran smoothly. Wasn't much of test though, since only half (15 or so) students did the lab simultaneously, and we only got to cover really simple hello-world kernels. Second edit: There were two servers, with two GeForce GTX 650 Tis per server

• cudaSetDevice(rand() % 4)? (I'm kidding...mostly...) – Nathan Reed Aug 2 '18 at 5:13
• I almost just settled for this myself but I got a headache thinking which seeding method would be best for load balancing – speedtsars Aug 2 '18 at 15:14

You need nvidia-docker. If your ssh server is in a Docker instance, you can assign each one to a different GPU. Then just set things up so only one team is sshing into each Docker instance. You don't need to do anything fancy with cudaSetDevice(), or risk students using the wrong device and messing things up for others, because each instance looks like it only has one GPU.