Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Limit GPU usage in nvidia-docker?

I am setting up an internal Jupyterhub on a multi GPU server. Jupyter access is provided through a docker instance. I'd like to limit access for each user to no more than a single GPU. I'd appreciate any suggestion or comment. Thanks.

like image 824
Dinesh K. Avatar asked Mar 12 '26 23:03

Dinesh K.


2 Answers

You can try it with nvidia-docker-compose

version: "2"
services
  process1:
    image: nvidia/cuda
    devices:
      - /dev/nvidia0
like image 113
opHASnoNAME Avatar answered Mar 15 '26 21:03

opHASnoNAME


There are 3 options.

Docker with NVIDIA RUNTIME (version 2.0.x)

According to official documentation

docker run --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=2,3

nvidia-docker (version 1.0.x)

based on a popular post

nvidia-docker run .... -e CUDA_VISIBLE_DEVICES=0,1,2

(it works with tensorflow)

programmatically

import os
os.environ["CUDA_VISIBLE_DEVICES"]="0,1,2"
like image 26
venergiac Avatar answered Mar 15 '26 21:03

venergiac



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!