安装 jupyter 在线记事本

创建日期: 2024-01-15 11:06 | 作者: 风波 | 浏览次数: 20 | 分类: PyTorch

1. 准备的文件

docker-compose.yml

version: "3" 
services:
  jupyter_server:
    image: ubuntu:22.04
    entrypoint: /docker-entrypoint.sh
    working_dir: /root/workspace
    ports:
      - 25780:80
    volumes:
      - ./workspace:/root/workspace
      - /mdata/data-for-dockers/jupyter_server/miniconda3:/opt/miniconda3
      - /mdata/data-for-dockers/jupyter_server/data:/opt/data
      - ./docker-entrypoint.sh:/docker-entrypoint.sh
      - /etc/localtime:/etc/localtime
    environment:
      - OSENV=ubuntu2204
    user: root

docker-entrypoint.sh

#!/bin/bash

. /opt/miniconda/bin/activate && \
cd /root/workspace && \
jupyter notebook --allow-root --port 80 --NotebookApp.allow_origin='*'  --NotebookApp.ip='0.0.0.0'

while true ; do
    sleep 10
done

Dockerfile

FROM ubuntu:22.04

USER root

COPY ./docker-entrypoint.sh /

install-deps.sh

#!/bin/bash

#wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh

pip install raise jupyter torch torchvision #d2l

2. 安装

  1. 启动 docker
  2. 进入 docker ,安装 miniconda。安装前先设置环境变量 export SHELL=bash下载地址:https://docs.conda.io/projects/miniconda/en/latest/ 。(https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh)
  3. 执行 install-deps.sh 安装 jupyter、torch、torchversion 等。需要下载的文件比较大。
  4. 重启容器,自动启动 jupyter 服务。
20 浏览
12 爬虫
0 评论