Spaces:
Sleeping
Sleeping
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' ๐ค | |
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() | |