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

  • 1
    $\begingroup$ cudaSetDevice(rand() % 4)? (I'm kidding...mostly...) $\endgroup$ Commented Aug 2, 2018 at 5:13
  • $\begingroup$ I almost just settled for this myself but I got a headache thinking which seeding method would be best for load balancing $\endgroup$
    – lil' wing
    Commented Aug 2, 2018 at 15:14

1 Answer 1


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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.