포스트

The Littlest JupyterHub 시작하기

  • 이 프로젝트는 현재 베타 상태입니다.
  • 단일 서버의 소수 (0-100) 사용자를위한 간단한 JupyterHub 배포입니다.
  • TLJH (The Littlest JupyterHub)는 Ubuntu 18.04 이상을 실행하는 모든 서버에서 실행할 수 있습니다

1. Clone the git repo

tljh 프로젝트를 클론하고, 해당 폴더로 들어갑니다.

git clone https://github.com/jupyterhub/the-littlest-jupyterhub.git
cd the-littlest-jupyterhub

2. Build docker

도커 이미지를 빌드하기전에 integration-tests/Dockerfile 파일을 원하는 입맛대로 수정합니다.

https://github.com/ju-ing/docker-jypyter/blob/main/Dockerfile

1
2
# docker build -t 이미지이름 . -f integration-tests/Dockerfile
docker build -t juing/jupyter:tljh-tf . -f integration-tests/Dockerfile

3. Run tljh iamge

  • privileged : 호스트 접근 권한
  • detach : 백그라운드로 실행
1
2
3
4
5
6
7
8
9
10
docker run \
  --privileged \
  --detach \
  --gpus=all \
  --restart=always \
  --publish 10080:80 \
  --publish 10443:443 \
  --name=tljh-tf \
  --mount type=bind,source=$(pwd),target=/srv/src \
  juing/jupyter:tljh-tf

mount 는 dockerfile 에서 copy 하셔도 되고 위에처럼 bind 하시거나 취향껏 하세요

4. Get a shell inside the container

1
docker exec -it tljh-tf /bin/bash
1
2
3
sudo python3 /srv/src/bootstrap/bootstrap.py \
  --admin admin \
  --user-requirements-txt-url https://raw.githubusercontent.com/ju-ing/docker-jypyter/main/requirements.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
root@973fe15d2fe5:/# python3 /srv/src/bootstrap/bootstrap.py --admin admin
Checking if TLJH is already installed...
Setting up hub environment
Installed python & virtual environment
Set up hub virtual environment
Setting up TLJH installer...
Upgraded pip
Setup tljh package
Install tensorflow-gpu
Starting TLJH installer...
Setting up admin users
Granting passwordless sudo to JupyterHub admins...
Setting up user environment...
Downloading & setting up user environment...
Setting up JupyterHub...
Downloading traefik 1.7.18...
Created symlink /etc/systemd/system/multi-user.target.wants/jupyterhub.service → /etc/systemd/system/jupyterhub.service.
Created symlink /etc/systemd/system/multi-user.target.wants/traefik.service → /etc/systemd/system/traefik.service.
Waiting for JupyterHub to come up (1/20 tries)
Waiting for JupyterHub to come up (2/20 tries)
Done!

5. TLJH Config.

1
2
3
cat /opt/tljh/config/config.yaml
or
sudo tljh-config show

Ports

which are 80 and 443 by default

1
2
3
sudo tljh-config set http.port 10080
sudo tljh-config set https.port 10443
sudo tljh-config reload proxy

User Server Limits

By default there is no memory limit.
By default there is no CPU limit.

1
2
3
sudo tljh-config set limits.memory 4G
sudo tljh-config set limits.cpu 2
sudo tljh-config reload

Change default User Interface for users

1
2
3
sudo tljh-config set user_environment.default_app jupyterlab
sudo tljh-config set user_environment.default_app nteract
sudo tljh-config reload

Extra User Groups

1
sudo tljh-config set users.extra_user_groups.group1 user1
1
2
sudo tljh-config add-item users.extra_user_groups.group1 user1
sudo tljh-config add-item users.extra_user_groups.group1 user2

Default settings

By default, JupyterHub will ping the user notebook servers every 60s to check their status. Every server found to be idle for more than 10 minutes will be culled.

1
2
services.cull.every = 60
services.cull.timeout = 600

Because the servers don’t have a maximum age set, an active server will not be shut down regardless of how long it has been up and running.

1
services.cull.max_age = 0

If after the culling process, there are users with no active notebook servers, by default, the users will not be culled alongside their notebooks and will continue to exist.

1
services.cull.users = False

Configuring the idle culler

Idle timeout

1
2
sudo tljh-config set services.cull.timeout <max-idle-sec-before-server-is-culled>
sudo tljh-config reload

Idle check interval

1
2
sudo tljh-config set services.cull.every <number-of-sec-this-check-is-done>
sudo tljh-config reload

Maximum age

1
2
sudo tljh-config set services.cull.max_age <server-max-age>
sudo tljh-config reload

User culling

1
2
sudo tljh-config set services.cull.users False
sudo tljh-config reload

Concurrency

1
2
sudo tljh-config set services.cull.concurrency <number-of-concurrent-hub-requests>
sudo tljh-config reload

Disabling the idle culler

1
2
sudo tljh-config set services.cull.enabled False
sudo tljh-config reload

6. 유저들을 위한 패키지 설치

The sudo -E is very important!

1
sudo -E pip install there

7. Tensorflow-gpu 작동 확인

1
2
3
4
5
6
import tensorflow as tf
from tensorflow.python.client import device_lib 

print("tf.__version__ : ", tf.__version__)
print("GPU 사용 가능 여부 :", tf.config.list_physical_devices('GPU'))
print(device_lib.list_local_devices())
이 기사는 저작권자의 CC BY 4.0 라이센스를 따릅니다.