This commit is contained in:
root 2025-06-11 14:16:54 +09:00
parent dd90783d6b
commit f8c5838554
6 changed files with 122 additions and 3 deletions

View File

@ -32,7 +32,7 @@ spec:
image: tensorflow/tensorflow:2.16.2-gpu-jupyter image: tensorflow/tensorflow:2.16.2-gpu-jupyter
resources: resources:
limits: limits:
nvidia.com/gpu: 1 nvidia.com/gpu: 2
ports: ports:
- containerPort: 8888 - containerPort: 8888
name: notebook name: notebook

View File

@ -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

View File

@ -0,0 +1,10 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: tf-notebook-pvc
namespace: org1
spec:
resources:
requests:
storage: 10Gi

View File

@ -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

View File

@ -2,8 +2,8 @@
# 변수 정의 # 변수 정의
NAMESPACE="org1" # 예: org1 NAMESPACE="org1" # 예: org1
POD_NAME="a2-tf-notebook-6bd88b8884-582nr" # 예: tf-notebook-abcdef POD_NAME="a7-tf-notebook-5b5ddb5f7-mmlqv" # 예: tf-notebook-abcdef
LOCAL_FILE="./sample.py" # 예: ./config.json LOCAL_FILE="./unlimit.py" # 예: ./config.json
TARGET_PATH="/tf" # 예: /app/config/ TARGET_PATH="/tf" # 예: /app/config/
# 멀티컨테이너가 아닐 경우 # 멀티컨테이너가 아닐 경우

47
monitoring/unlimit.py Normal file
View File

@ -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")