构建支持 gpu 的 jupyterlab docker 镜像

1. 创建 Dockerfile

创建一个 Dockerfile 文件,内容如下

FROM docker.io/nvidia/cuda:12.2.2-cudnn8-runtime-ubuntu22.04

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get upgrade -y && \
    apt-get install -y --no-install-recommends \
    libgl1 libglib2.0-0 wget git curl vim \
    python3.10 python3-pip python3-dev build-essential \
    openmpi-bin libopenmpi-dev jupyter-notebook jupyter

RUN pip3 install tensorrt_llm -U --extra-index-url https://pypi.nvidia.com
RUN pip3 install --upgrade jinja2==3.0.3 pynvml>=11.5.0

RUN rm -rf /var/cache/apt/ && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
    rm -rf /root/.cache/pip/ && rm -rf /*.whl

WORKDIR /root/work
ENTRYPOINT ["sh","-c","jupyter notebook --allow-root --notebook-dir=/root/work --port=8888 --ip=0.0.0.0 --ServerApp.token=''"]

2. 构建镜像

docker buildx build -t engchina/gpu-jupyter:latest -f Dockerfile .

3. 启动 gpu-jupyter

mkdir /u01/data/gpu-jupyter-work; chmod 777 /u01/data/gpu-jupyter-work
docker run --gpus all -d --name gpu-jupyter-work -p 9888:8888 -v /u01/data/gpu-jupyter-work:/root/work -e GRANT_SUDO=yes -e JUPYTER_ENABLE_LAB=yes --user root engchina/gpu-jupyter:latest

4. 访问 gpu-jupyter

查看 gpu-jupyter 的 login token,

token=$(docker exec -it gpu-jupyter-work jupyter server list | grep -oP '(?<=token=)[a-zA-Z0-9]+')
echo $token

使用浏览器打开 http://<your_ip>:9888/lab 进行访问,输入 token 进行登录。

完结!

相关推荐

  1. 构建支持 gpu jupyterlab docker 镜像

    2024-01-27 12:24:02       35 阅读
  2. Docker 镜像构建最佳做法

    2024-01-27 12:24:02       38 阅读
  3. 如何构建自己Docker镜像

    2024-01-27 12:24:02       27 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-01-27 12:24:02       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-01-27 12:24:02       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-01-27 12:24:02       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-01-27 12:24:02       20 阅读

热门阅读

  1. [go] 享元模式

    2024-01-27 12:24:02       37 阅读
  2. GBASE南大通用分享-linux centos下安装dokuwiki

    2024-01-27 12:24:02       26 阅读
  3. centos搭建ftp踩坑记录

    2024-01-27 12:24:02       26 阅读
  4. 四、MySQL之DML && DQL

    2024-01-27 12:24:02       32 阅读
  5. 排序算法——希尔排序算法详解

    2024-01-27 12:24:02       29 阅读
  6. 实习记录——第五天

    2024-01-27 12:24:02       30 阅读