3

我正在多 GPU 服务器上设置内部 Jupyterhub。Jupyter 访问是通过 docker 实例提供的。我想将每个用户的访问权限限制为不超过一个 GPU。我很感激任何建议或评论。谢谢。

4

3 回答 3

2

你可以试试nvidia-docker-compose

version: "2"
services
  process1:
    image: nvidia/cuda
    devices:
      - /dev/nvidia0
于 2017-02-18T10:58:12.843 回答
1

问题可以这样解决,只需在“nvidia-docker”之前添加环境变量“NV_GPU”如下:


 [root@bogon ~]# NV_GPU='4,5' nvidia-docker run -dit --name tf_07 tensorflow/tensorflow:latest-gpu /bin/bash
e04645c2d7ea658089435d64e72603f69859a3e7b6af64af005fb852473d6b56
[root@bogon ~]# docker attach tf_07
root@e04645c2d7ea:/notebooks#
root@e04645c2d7ea:/notebooks# ll /dev
total 4
drwxr-xr-x  5 root root      460 Dec 29 03:52 ./
drwxr-xr-x 22 root root     4096 Dec 29 03:52 ../
crw--w----  1 root tty  136,   0 Dec 29 03:53 console
lrwxrwxrwx  1 root root       11 Dec 29 03:52 core -> /proc/kcore
lrwxrwxrwx  1 root root       13 Dec 29 03:52 fd -> /proc/self/fd/
crw-rw-rw-  1 root root   1,   7 Dec 29 03:52 full
drwxrwxrwt  2 root root       40 Dec 29 03:52 mqueue/
crw-rw-rw-  1 root root   1,   3 Dec 29 03:52 null
crw-rw-rw-  1 root root 245,   0 Dec 29 03:52 nvidia-uvm
crw-rw-rw-  1 root root 245,   1 Dec 29 03:52 nvidia-uvm-tools
crw-rw-rw-  1 root root 195,   4 Dec 29 03:52 nvidia4
crw-rw-rw-  1 root root 195,   5 Dec 29 03:52 nvidia5
crw-rw-rw-  1 root root 195, 255 Dec 29 03:52 nvidiactl
lrwxrwxrwx  1 root root        8 Dec 29 03:52 ptmx -> pts/ptmx
drwxr-xr-x  2 root root        0 Dec 29 03:52 pts/
crw-rw-rw-  1 root root   1,   8 Dec 29 03:52 random
drwxrwxrwt  2 root root       40 Dec 29 03:52 shm/
lrwxrwxrwx  1 root root       15 Dec 29 03:52 stderr -> /proc/self/fd/2
lrwxrwxrwx  1 root root       15 Dec 29 03:52 stdin -> /proc/self/fd/0
lrwxrwxrwx  1 root root       15 Dec 29 03:52 stdout -> /proc/self/fd/1
crw-rw-rw-  1 root root   5,   0 Dec 29 03:52 tty
crw-rw-rw-  1 root root   1,   9 Dec 29 03:52 urandom
crw-rw-rw-  1 root root   1,   5 Dec 29 03:52 zero
root@e04645c2d7ea:/notebooks#

或者,阅读github wiki 的 nvidia-docker

于 2017-12-29T03:57:11.247 回答
0

有 3 个选项。

带有 NVIDIA RUNTIME 的 Docker(版本 2.0.x)

根据官方文档

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

nvidia-docker(版本 1.0.x)

基于热门帖子

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

(它适用于张量流)

以编程方式

import os
os.environ["CUDA_VISIBLE_DEVICES"]="0,1,2"
于 2019-05-06T05:38:14.797 回答