docker内的/dev/shm

docker内的/dev/shm,默认共享的是64M。

pm@TR:/data/factory$ sudo docker exec -it 6d401ddd44d2 bash

root@6d401ddd44d2:/# df -h /dev/shm

Filesystem      Size  Used Avail Use% Mounted on

shm              64M     0   64M   0% /dev/shm

现有几个算法跑在同一个docker中,需要它们在docker中共享1G内存

解决方法:在对应的容器中添加shm_size参数,并将1G换算成字节1073741824(红色字体所示),贴上yml代码:

  BrilliantFactory:

    image: nvidia/cuda:10.0-cudnn7-runtime

    container_name: factory_BrilliantFactory

    runtime: nvidia

    privileged: true

    cap_add: 

      - SYS_PTRACE

    ports:

      - 8689:12345

    volumes:

      - /etc/timezone:/etc/timezone:ro

      - /etc/localtime:/etc/localtime:ro

      - ./docker-app-BrilliantFactory:/app

    environment:

      - NVIDIA_VISIBLE_DEVICES=all

      - NVIDIA_DRIVER_CAPABILITIES=compute,utility,video

    command: /app/BrilliantFactory/bin/start.sh

    stdin_open: true

    # tty: true

    shm_size: 1073741824

     restart: always

验证:

pm@TR:/data/factory$ sudo docker exec -it 6d401ddd44d2 bash

root@6d401ddd44d2:/# df -h /dev/shm

Filesystem      Size  Used Avail Use% Mounted on

shm             1.0G   74M  951M   8% /dev/shm

结束。

 

posted @ 2020-04-27 21:26  巴州夜雨  阅读(3114)  评论(0编辑  收藏  举报