File size: 977 Bytes
7197456
 
9c85732
 
 
622f8d4
 
 
 
 
7197456
9c85732
622f8d4
 
9c85732
8c2b61b
622f8d4
 
9c85732
7197456
 
 
9c85732
 
 
7197456
 
9c85732
 
7197456
 
 
b194cd1
7197456
 
3f8ee6d
 
7b99542
34619cb
7b99542
 
7197456
 
 
 
 
 
 
10ecedc
7197456
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
import spaces 
import gradio as gr 
import platform
import os;
import socket;
import torch

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

RandomTensor = torch.randn(1, 2)  # Example audio tensor

def sysinfo():
    tensorExample = RandomTensor.to(device)
    
    return f"""

       hostname: {platform.node()} {socket.gethostname()}

       device: {device}

       tensor: {tensorExample}

    """;

@spaces.GPU
def gpu():

     return sysinfo();


def nogpu():
    
    return sysinfo();



with gr.Blocks() as demo:
    outgpu = gr.Textbox(lines=5);
    outnpu = gr.Textbox(lines=5);
    btngpu = gr.Button(value="gpu");
    btngpun = gr.Button(value="ngpu");
    
    btngpu.click(gpu, None, [outgpu]);
    btngpun.click(nogpu, None, [outnpu]);
    


if __name__ == "__main__":
    demo.launch(
        share=False,
        debug=False,
        server_port=7860,
        server_name="0.0.0.0"
    )