apiVersion: traefik.containo.us/v1alpha1 kind: IngressRoute metadata: name: wordslab-notebooks-ingressroute labels: wordslab.org/app: wordslab-notebooks wordslab.org/component: jupyterlab annotations: wordslab.org/namespace-default: "notebooks" wordslab.org/title: "Jupyterlab notebooks (GPU)" wordslab.org/description: "Ubuntu 22.04, Cuda 12.2, Python 3.10, Pytorch 2.0 / Tensorflow 2.13 / JAX 0.4 / scikit-learn 0.23, Jupyterlab 3.6" wordslab.org/version: "jupyterlab-3.6.5-lambda-0.1.14-22.04.1_2" wordslab.org/date: "09/17/2023" wordslab.org/homepage: "https://www.wordslab.org/" wordslab.org/source: "https://github.com/wordslab-org/wordslab/tree/main/wordslab.manager/apps/notebooks/wordslab-notebooks-gpu-app.yaml" wordslab.org/author: "https://github.com/wordslab-org" wordslab.org/license: "Apache License Version 2.0" wordslab.org/ingressroute-path: "/lab | Jupyterlab" wordslab.org/ingressroute-path1: "/gradio | Web interface (port 7860)" wordslab.org/ingressroute-path2: "/fastapi | API endpoint (port 8000)" spec: entryPoints: - web routes: - match: PathPrefix(`/$$namespace$$`) kind: Rule services: - name: wordslab-notebooks-service port: 8888 - match: PathPrefix(`/$$namespace$$/gradio`) kind: Rule services: - name: wordslab-gradio-service port: 7860 middlewares: - name: wordslab-stripprefix-gradio - match: PathPrefix(`/$$namespace$$/fastapi`) kind: Rule services: - name: wordslab-fastapi-service port: 8000 middlewares: - name: wordslab-stripprefix-fastapi --- apiVersion: traefik.containo.us/v1alpha1 kind: Middleware metadata: name: wordslab-stripprefix-gradio labels: wordslab.org/app: wordslab-notebooks wordslab.org/component: jupyterlab spec: stripPrefix: prefixes: - /$$namespace$$/gradio --- apiVersion: traefik.containo.us/v1alpha1 kind: Middleware metadata: name: wordslab-stripprefix-fastapi labels: wordslab.org/app: wordslab-notebooks wordslab.org/component: jupyterlab spec: stripPrefix: prefixes: - /$$namespace$$/fastapi --- apiVersion: v1 kind: Service metadata: name: wordslab-notebooks-service labels: wordslab.org/app: wordslab-notebooks wordslab.org/component: jupyterlab spec: type: ClusterIP ports: - port: 8888 targetPort: http protocol: TCP name: http selector: wordslab.org/app: wordslab-notebooks wordslab.org/component: jupyterlab --- apiVersion: v1 kind: Service metadata: name: wordslab-gradio-service labels: wordslab.org/app: wordslab-notebooks wordslab.org/component: jupyterlab spec: type: ClusterIP ports: - port: 7860 targetPort: 7860 protocol: TCP selector: wordslab.org/app: wordslab-notebooks wordslab.org/component: jupyterlab --- apiVersion: v1 kind: Service metadata: name: wordslab-fastapi-service labels: wordslab.org/app: wordslab-notebooks wordslab.org/component: jupyterlab spec: type: ClusterIP ports: - port: 8000 targetPort: 8000 protocol: TCP selector: wordslab.org/app: wordslab-notebooks wordslab.org/component: jupyterlab --- kind: "PersistentVolumeClaim" apiVersion: "v1" metadata: name: wordslab-notebooks-workspace-volume labels: wordslab.org/app: wordslab-notebooks wordslab.org/component: workspace-volume annotations: wordslab.org/title: "User projects files and data" wordslab.org/description: "Volume where the user projects repositories are stored" spec: accessModes: - "ReadWriteOnce" storageClassName: local-path resources: requests: storage: 5Gi --- kind: "PersistentVolumeClaim" apiVersion: "v1" metadata: name: wordslab-notebooks-models-volume labels: wordslab.org/app: wordslab-notebooks wordslab.org/component: models-volume annotations: wordslab.org/title: "Shared models and datasets files" wordslab.org/description: "Volume where the shared models and datasets are stored" spec: accessModes: - "ReadWriteOnce" storageClassName: local-path resources: requests: storage: 5Gi --- apiVersion: apps/v1 kind: Deployment metadata: name: wordslab-notebooks-deployment labels: wordslab.org/app: wordslab-notebooks wordslab.org/component: jupyterlab spec: replicas: 1 selector: matchLabels: wordslab.org/app: wordslab-notebooks wordslab.org/component: jupyterlab template: metadata: labels: wordslab.org/app: wordslab-notebooks wordslab.org/component: jupyterlab spec: containers: - name: wordslab-jupyter-stack-container image: ghcr.io/wordslab-org/jupyter-stack-cuda:jupyterlab-3.6.5-lambda-0.1.14-22.04.1_2 ports: - name: http containerPort: 8888 protocol: TCP env: - name: JUPYTER_BASE_URL value: "/$$namespace$$" - name: JUPYTER_PORT value: "8888" - name: JUPYTER_TOKEN value: "" - name: JUPYTER_ROOT_DIR value: "/" - name: JUPYTER_SETUP_SCRIPT value: "/setup.sh" # Temporary fix for the first version of the jupyter-stack image: bug already fixed in the Dockerfile for the next rebuild - name: JUPYTERLAB_SETTINGS_DIR value: "/workspace/.jupyter/lab/user-settings/" - name: JUPYTERLAB_WORKSPACES_DIR value: "/workspace/.jupyter/lab/workspaces" # end of temporary fix - name: NVIDIA_VISIBLE_DEVICES value: "all" - name: NVIDIA_DRIVER_CAPABILITIES value: "compute,utility" - name: NVIDIA_REQUIRE_CUDA value: "cuda>=11.8" # https://huggingface.co/docs/huggingface_hub/package_reference/environment_variables#hfhome # https://huggingface.co/transformers/v4.0.1/installation.html#caching-models # https://huggingface.co/docs/datasets/v1.18.2/cache.html#cache-directory - name: HF_HOME value: "/models/huggingface" - name: TRANSFORMERS_CACHE value: "/models/huggingface/transformers" - name: HF_DATASETS_CACHE value: "/models/huggingface/datasets" # https://docs.fast.ai/data.external.html#config - name: FASTAI_HOME value: "/models/fastai" # https://pytorch.org/docs/stable/hub.html#where-are-my-downloaded-models-saved - name: TORCH_HOME value: "/models/torch" # There is no way to set the cache directory in Keras: # https://github.com/keras-team/keras/blob/f9336cc5114b4a9429a242deb264b707379646b7/keras/utils/data_utils.py#L268 # But we can store the config in the shared directory: # https://github.com/tensorflow/tensorflow/blob/9a679fd0fdd807be9d0c0a2c7846e61364f70625/tensorflow/python/keras/backend.py#L6374 - name: KERAS_HOME value: "/models/keras" # https://www.tensorflow.org/hub/caching?hl=fr - name: TFHUB_CACHE_DIR value: /models/tfhub_modules" - name: GRADIO_BASE_URL value: "/$$namespace$$/gradio" - name: GRADIO_PORT value: "7860" - name: FASTAPI_BASE_URL value: "/$$namespace$$/fastapi" - name: FASTAPI_PORT value: "8000" volumeMounts: - name: dshm mountPath: /dev/shm - name: workspace mountPath: /workspace - name: models mountPath: /models volumes: - name: dshm emptyDir: medium: Memory - name: workspace persistentVolumeClaim: claimName: wordslab-notebooks-workspace-volume - name: models persistentVolumeClaim: claimName: wordslab-notebooks-models-volume