Files
docker-jupyterhub/jupyterhub_config_self.py

49 lines
1.3 KiB
Python
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import os
c = get_config() # noqa: F821
# 基本配置
c.Authenticator.allow_all = True
c.JupyterHub.spawner_class = "jupyterhub.spawner.LocalProcessSpawner"
# 单用户配置
c.Spawner.cmd = ['jupyter-labhub']
c.Spawner.default_url = '/lab'
c.Spawner.notebook_dir = '/home/jovyan'
c.Spawner.environment = {
'JUPYTER_ENABLE_LAB': 'yes',
'NOTEBOOK_ARGS': '--NotebookApp.allow_origin="*" --NotebookApp.iopub_data_rate_limit=10000000',
}
# Hub IP 和端口配置
c.JupyterHub.hub_ip = '0.0.0.0'
c.JupyterHub.hub_port = 8080
# Cookie secret 和数据库 URL
c.JupyterHub.cookie_secret_file = '/srv/jupyterhub/jupyterhub_cookie_secret'
c.JupyterHub.db_url = 'sqlite:////srv/jupyterhub/jupyterhub.sqlite'
# Authenticator 配置
c.JupyterHub.authenticator_class = 'nativeauthenticator.NativeAuthenticator'
c.NativeAuthenticator.open_signup = True
# 管理员配置
admin = os.environ.get('JUPYTERHUB_ADMIN')
if admin:
c.Authenticator.admin_users = {admin}
# 调试模式
c.JupyterHub.log_level = 'DEBUG'
c.Spawner.debug = True
# GPU 和网络配置(仅在需要 GPU 时启用)
c.Spawner.environment.update({
'NVIDIA_DRIVER_CAPABILITIES': 'compute,utility',
'NVIDIA_VISIBLE_DEVICES': 'all'
})
# 可选GPU runtime 配置
c.Spawner.extra_host_config = {
'runtime': 'nvidia'
}