<p>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 <code>cudaSetDevice()</code>, or risk students using the wrong device and messing things up for others, because each instance looks like it only has one GPU.</p>

CC BY-SA 4.0
2018-07-22T10:31:14.960Z
2018-07-22T10:31:14.960Z
Dan Hulme
<p>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. </p>

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

<p>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().</p>

<p>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</p>

CC BY-SA 4.0
2018-08-02T05:13:03.360Z
`cudaSetDevice(rand() % 4)`? (I'm kidding...mostly...)
Nathan Reed
CC BY-SA 4.0
2018-08-02T15:14:53.833Z
I almost just settled for this myself but I got a headache thinking which seeding method would be best for load balancing
lil' wing
<gpgpu><cuda>
How to avoid slowdown with 25-30 students running simple GPU kernels on 4 GeForce GTX 650 Ti s?
lil' wing
# How to avoid slowdown with 25-30 students running simple GPU kernels on 4 GeForce GTX 650 Ti s?

(Asked by: username_0 on 2018-07-19)

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

**Tags:** gpgpu, cuda

> **Comments:**
> **username_1**: `cudaSetDevice(rand() % 4)`? (I'm kidding...mostly...)  
> **username_0**: I almost just settled for this myself but I got a headache thinking which seeding method would be best for load balancing  

---

## 1 answers

### Answer by username_2 on 2018-07-22. Score: 2 | Accepted answer

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.


---

