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' }