firsttry / app.py
s2337a's picture
Update app.py
fc26491 verified
raw
history blame
2.4 kB
# Load model directly
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("snunlp/KR-FinBert-SC")
model = AutoModelForSequenceClassification.from_pretrained("snunlp/KR-FinBert-SC")
import os
import tensorflow as tf
from absl import logging
# ν™˜κ²½ λ³€μˆ˜ μ„€μ •
os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0' # oneDNN μ΅œμ ν™” λΉ„ν™œμ„±ν™”
# 둜그 μ΄ˆκΈ°ν™”
logging.set_verbosity(logging.INFO)
logging.use_absl_handler()
# GPU μ„€μ •
gpus = tf.config.experimental.list_physical_devices('GPU')
if gpus:
try:
for gpu in gpus:
tf.config.experimental.set_memory_growth(gpu, True)
print("GPU λ©”λͺ¨λ¦¬ 증가 ν—ˆμš© μ„€μ • μ™„λ£Œ")
except RuntimeError as e:
print(f"GPU μ„€μ • 였λ₯˜: {e}")
# TensorFlow 및 μ‹œμŠ€ν…œ 정보 확인
print("TensorFlow 버전:", tf.__version__)
print("μ‚¬μš© κ°€λŠ₯ν•œ μž₯치:", tf.config.list_physical_devices())
import os
import tensorflow as tf
# oneDNN μ΅œμ ν™” λΉ„ν™œμ„±ν™”
os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0'
# GPU λΉ„ν™œμ„±ν™” (CUDA 문제 ν•΄κ²° μ‹œ)
os.environ["CUDA_VISIBLE_DEVICES"] = "-1"
# TensorFlow GPU λ©”λͺ¨λ¦¬ μ„€μ •
gpus = tf.config.experimental.list_physical_devices('GPU')
if gpus:
try:
for gpu in gpus:
tf.config.experimental.set_memory_growth(gpu, True)
print("GPU λ©”λͺ¨λ¦¬ 증가 ν—ˆμš© μ„€μ • μ™„λ£Œ")
except RuntimeError as e:
print(f"GPU μ„€μ • 였λ₯˜: {e}")
# TensorFlow μ‹€ν–‰ 확인
print("TensorFlow 버전:", tf.__version__)
print("μ‚¬μš© κ°€λŠ₯ν•œ μž₯치:", tf.config.list_physical_devices())
# Base image
FROM python:3.10-slim
# Install Python packages
RUN pip install --no-cache-dir pip==22.3.1 \
&& pip install --no-cache-dir datasets "huggingface-hub>=0.19" \
"hf-transfer>=0.1.4" "protobuf<4" "click<8.1" "pydantic~=1.0"
# Install system packages
RUN apt-get update && apt-get install -y \
git git-lfs ffmpeg libsm6 libxext6 cmake rsync libgl1-mesa-glx \
&& rm -rf /var/lib/apt/lists/*
# Work directory
WORKDIR /home/user/app
# Copy requirements and install additional Python packages
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy source code
COPY . .
# Set default command
CMD ["streamlit", "run", "app.py"]
import streamlit as st
st.title("Hello, Streamlit!")
st.write("This is a sample Streamlit app.")