test-stfzip / app.py
yerang's picture
Update app.py
6fa08f7 verified
raw
history blame
1.35 kB
import gradio as gr
import spaces
import torch
import gdown
import os
import setup_environment
import zipfile
import sys
from setup_environment import initialize_environment
zero = torch.Tensor([0]).cuda()
print(zero.device) # <-- 'cpu' ๐Ÿค”
@spaces.GPU
def greet(n):
print(zero.device) # <-- 'cuda:0' ๐Ÿค—
initialize_environment()
sys.path.append('/home/user/.local/lib/python3.10/site-packages')
sys.path.append('/home/user/.local/lib/python3.10/site-packages/stf_alternative/src/stf_alternative')
sys.path.append('/home/user/.local/lib/python3.10/site-packages/stf_tools/src/stf_tools')
sys.path.append('/tmp/')
sys.path.append('/tmp/stf/')
sys.path.append('/tmp/stf/stf_alternative/')
sys.path.append('/tmp/stf/stf_alternative/src/stf_alternative')
# CUDA ๊ฒฝ๋กœ๋ฅผ ํ™˜๊ฒฝ ๋ณ€์ˆ˜๋กœ ์„ค์ •
os.environ['PATH'] = '/usr/local/cuda/bin:' + os.environ.get('PATH', '')
os.environ['LD_LIBRARY_PATH'] = '/usr/local/cuda/lib64:' + os.environ.get('LD_LIBRARY_PATH', '')
# ํ™•์ธ์šฉ ์ถœ๋ ฅ
print("PATH:", os.environ['PATH'])
print("LD_LIBRARY_PATH:", os.environ['LD_LIBRARY_PATH'])
from stf_utils import STFPipeline
return f"Hello {zero + n} Tensor"
demo = gr.Interface(fn=greet, inputs=gr.Number(), outputs=gr.Text())
demo.launch()