• Linux Docker容器配置


    1. Installing the NVIDIA Container Toolkit

    Installing the NVIDIA Container Toolkit — container-toolkit 1.14.1 documentation
    a. Configure the repository

    1. curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
    2. && curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \
    3. sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
    4. sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list \
    5. && \
    6. sudo apt-get update

    b. Install the NVIDIA Container Toolkit packages:

    sudo apt-get install -y nvidia-container-toolkit

    c. Configuring Docker

    Configure the container runtime by using the nvidia-ctk command:

    sudo nvidia-ctk runtime configure --runtime=docker

    The nvidia-ctk command modifies the /etc/docker/daemon.json file on the host. The file is updated so that Docker can use the NVIDIA Container Runtime.

    Restart the Docker daemon:

    sudo systemctl restart docker

    2. docker hub 镜像

    a. 添加国内镜像

    vi /etc/docker/daemon.json
    1. {
    2. "runtimes": {
    3. "nvidia": {
    4. "args": [],
    5. "path": "nvidia-container-runtime"
    6. }
    7. },
    8. "registry-mirrors":[
    9. "https://mirror.ccs.tencentyun.com",
    10. "http://registry.docker-cn.com",
    11. "http://docker.mirrors.ustc.edu.cn",
    12. "http://hub-mirror.c.163.com",
    13. "https://3laho3y3.mirror.aliyuncs.com",
    14. "http://f1361db2.m.daocloud.io",
    15. "https://docker.mirrors.sjtug.sjtu.edu.cn",
    16. "https://docker.nju.edu.cn",
    17. "https://dockerproxy.com",
    18. "https://mirror.baidubce.com"
    19. ],
    20. "insecure-registries":[
    21. "registry.docker-cn.com",
    22. "docker.mirrors.ustc.edu.cn"
    23. ],
    24. "debug":true,
    25. "experimental":true
    26. }

    b. 拉取镜像

    sudo docker pull nvidia/cuda:11.7.1-cudnn8-devel-ubuntu20.04
    

    需要等待较长时间1-2小时。

    c. 创建容器

    docker run -it -d --gpus all --name NLP_env --hostname NLP_env --shm-size 8g -e NVIDIA_DRIVER_CAPABILITIES=compute,utility,video -v /home/modeldata:/containerdata -p 6667:22 --restart always nvidia/cuda:11.7.1-cudnn8-devel-ubuntu20.04 /bin/bash

    -d 后台运行

    --gpus all 选择所有gpu

    --name 容器名称

    --hostname 主机名称

    --shm-size 共享内存

    -e 环境设置 这里NVIDIA_DRIVER_CAPABILITIES主要保证容器里能够查看并且使用显卡

    -v 目录映射(宿主机:容器内)

    -p 端口映射(宿主机:容器内)

    --restart always 重启启动

    运行

    docker ps -a

    显示

    测试通过

    docker exec -it NLP_env nvidia-smi

    查看显卡是否在容器内运行正常。

    d. 进入容器

    docker exec -it NLP_env bash

    e. 安装openssh-server

    1. apt update
    2. apt install openssh-server
    3. apt install vim
    4. vim /etc/ssh/sshd_config

    将sshd_config内容修改PermitRootLogin yes

    1. service ssh restart
    2. passwd

    输入登录密码并确认。

    之后可以通过ssh,登录IP,端口号6667,账号root,密码登录即可。

  • 相关阅读:
    C#,人工智能,机器人路径规划(Robotics Pathfinding)DStarLite(D* Lite Algorithm)优化算法与C#源程序
    uni-app:单页面的页面切换
    数据结构与算法之矩阵: Leetcode 134. 螺旋矩阵 (Typescript版)
    文献速递:深度学习乳腺癌诊断---基于深度学习的图像分析预测乳腺癌中H&E染色组织病理学图像的PD-L1状态
    Linux 环境定制.bashrc 文件
    网络中使用最多的图片格式有哪些
    Maven生命周期与插件
    Golang 一日一库之jwt-go
    详解(一)-ThreadPollExecutor-并发编程(Java)
    大数据杂谈
  • 原文地址:https://blog.csdn.net/shadowismine/article/details/132863728