From f8c583855492c9f30f49c90b2f9c92002d6db4e9 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 11 Jun 2025 14:16:54 +0900 Subject: [PATCH] new --- gpuaas/jupyter_kustomize/base/tf.yaml | 2 +- .../overlays/7_jupyter/kustomization.yaml | 16 +++++++ .../overlays/7_jupyter/patch-pvc.yaml | 10 ++++ .../overlays/7_jupyter/test.yaml | 46 ++++++++++++++++++ monitoring/scp.sh | 4 +- monitoring/unlimit.py | 47 +++++++++++++++++++ 6 files changed, 122 insertions(+), 3 deletions(-) create mode 100644 gpuaas/jupyter_kustomize/overlays/7_jupyter/kustomization.yaml create mode 100644 gpuaas/jupyter_kustomize/overlays/7_jupyter/patch-pvc.yaml create mode 100644 gpuaas/jupyter_kustomize/overlays/7_jupyter/test.yaml create mode 100644 monitoring/unlimit.py diff --git a/gpuaas/jupyter_kustomize/base/tf.yaml b/gpuaas/jupyter_kustomize/base/tf.yaml index 313b63d..c4770d0 100644 --- a/gpuaas/jupyter_kustomize/base/tf.yaml +++ b/gpuaas/jupyter_kustomize/base/tf.yaml @@ -32,7 +32,7 @@ spec: image: tensorflow/tensorflow:2.16.2-gpu-jupyter resources: limits: - nvidia.com/gpu: 1 + nvidia.com/gpu: 2 ports: - containerPort: 8888 name: notebook diff --git a/gpuaas/jupyter_kustomize/overlays/7_jupyter/kustomization.yaml b/gpuaas/jupyter_kustomize/overlays/7_jupyter/kustomization.yaml new file mode 100644 index 0000000..1884717 --- /dev/null +++ b/gpuaas/jupyter_kustomize/overlays/7_jupyter/kustomization.yaml @@ -0,0 +1,16 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: + - ../../base + +namePrefix: a7- +namespace: org1 + + +patches: + - path: patch-pvc.yaml + target: + kind: PersistentVolumeClaim + name: tf-notebook-pvc + namespace: org1 diff --git a/gpuaas/jupyter_kustomize/overlays/7_jupyter/patch-pvc.yaml b/gpuaas/jupyter_kustomize/overlays/7_jupyter/patch-pvc.yaml new file mode 100644 index 0000000..63047c0 --- /dev/null +++ b/gpuaas/jupyter_kustomize/overlays/7_jupyter/patch-pvc.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: tf-notebook-pvc + namespace: org1 +spec: + resources: + requests: + storage: 10Gi + diff --git a/gpuaas/jupyter_kustomize/overlays/7_jupyter/test.yaml b/gpuaas/jupyter_kustomize/overlays/7_jupyter/test.yaml new file mode 100644 index 0000000..fd6f6bb --- /dev/null +++ b/gpuaas/jupyter_kustomize/overlays/7_jupyter/test.yaml @@ -0,0 +1,46 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: a1-tf-notebook-pvc + namespace: org2 +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 10Gi + storageClassName: nfs-client +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: a1-tf-notebook + namespace: org2 +spec: + replicas: 1 + selector: + matchLabels: + app: tf-notebook + template: + metadata: + labels: + app: tf-notebook + spec: + containers: + - image: tensorflow/tensorflow:2.16.2-gpu-jupyter + name: tf-notebook + ports: + - containerPort: 8888 + name: notebook + resources: + limits: + nvidia.com/gpu: 1 + volumeMounts: + - mountPath: /sample + name: notebook-storage + nodeSelector: + nodegroup: gpu + volumes: + - name: notebook-storage + persistentVolumeClaim: + claimName: a1-tf-notebook-pvc diff --git a/monitoring/scp.sh b/monitoring/scp.sh index f509f8e..f59700d 100755 --- a/monitoring/scp.sh +++ b/monitoring/scp.sh @@ -2,8 +2,8 @@ # 변수 정의 NAMESPACE="org1" # 예: org1 -POD_NAME="a2-tf-notebook-6bd88b8884-582nr" # 예: tf-notebook-abcdef -LOCAL_FILE="./sample.py" # 예: ./config.json +POD_NAME="a7-tf-notebook-5b5ddb5f7-mmlqv" # 예: tf-notebook-abcdef +LOCAL_FILE="./unlimit.py" # 예: ./config.json TARGET_PATH="/tf" # 예: /app/config/ # 멀티컨테이너가 아닐 경우 diff --git a/monitoring/unlimit.py b/monitoring/unlimit.py new file mode 100644 index 0000000..e0c4921 --- /dev/null +++ b/monitoring/unlimit.py @@ -0,0 +1,47 @@ +import tensorflow as tf +from tensorflow.keras import layers, models +import numpy as np +import time + +# 모델 평가 시작 시간 기록 +start_time = time.time() + +# 데이터셋 로드 및 전처리 +(x_train, y_train), (x_test, y_test) = tf.keras.datasets.mnist.load_data() + +# 데이터 정규화 및 차원 확장 +x_train = x_train / 255.0 +x_test = x_test / 255.0 +x_train = np.expand_dims(x_train, -1) +x_test = np.expand_dims(x_test, -1) + +# 간단한 CNN 모델 정의 +model = models.Sequential([ + layers.Conv2D(32, (3, 3), activation='relu', input_shape=(28, 28, 1)), + layers.MaxPooling2D((2, 2)), + layers.Conv2D(64, (3, 3), activation='relu'), + layers.MaxPooling2D((2, 2)), + layers.Flatten(), + layers.Dense(64, activation='relu'), + layers.Dense(10, activation='softmax') +]) + +# 모델 컴파일 +model.compile(optimizer='adam', + loss='sparse_categorical_crossentropy', + metrics=['accuracy']) + +# 모델 요약 +model.summary() + +# 모델 훈련 +model.fit(x_train, y_train, epochs=500, batch_size=256, validation_split=0.2) + +# 모델 평가 +test_loss, test_acc = model.evaluate(x_test, y_test, verbose=2) +print(f"Test accuracy: {test_acc:.2f}") + +# 모델 평가 종료 시간 기록 및 출력 +end_time = time.time() +print(f"Evaluation time: {end_time - start_time:.2f} seconds") +