File size: 1,348 Bytes
c2d4056
 
 
a2c05a5
 
 
5a51b84
9e7ee92
5a51b84
c2d4056
 
 
 
 
 
 
a2c05a5
b9ca010
5a51b84
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ff68179
5a51b84
03e69dc
 
 
 
ff68179
 
5a51b84
 
a2c05a5
 
c2d4056
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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()