demo 1
Browse files
app.py
CHANGED
@@ -4,41 +4,30 @@ import platform
|
|
4 |
import os;
|
5 |
import socket;
|
6 |
import torch
|
7 |
-
import torch.nn as nn
|
8 |
|
9 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
10 |
|
11 |
-
class SimpleModel(nn.Module):
|
12 |
-
def __init__(self):
|
13 |
-
super(SimpleModel, self).__init__()
|
14 |
|
15 |
-
def forward(self, x):
|
16 |
-
pass
|
17 |
-
|
18 |
-
@property
|
19 |
-
def device(self):
|
20 |
-
return next(model.parameters()).device
|
21 |
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
def sysinfo():
|
26 |
|
27 |
return f"""
|
28 |
hostname: {platform.node()} {socket.gethostname()}
|
29 |
device: {device}
|
30 |
-
model device: {model.device}
|
31 |
tensor: {tensorExample}
|
32 |
""";
|
33 |
|
34 |
@spaces.GPU
|
35 |
def gpu():
|
36 |
-
return sysinfo();
|
37 |
|
|
|
38 |
|
39 |
-
def nogpu():
|
40 |
|
41 |
-
|
|
|
|
|
42 |
|
43 |
|
44 |
|
|
|
4 |
import os;
|
5 |
import socket;
|
6 |
import torch
|
|
|
7 |
|
8 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
9 |
|
|
|
|
|
|
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
+
def sysinfo(device):
|
13 |
+
RandomTensor = torch.randn(1, 2) # Example audio tensor
|
14 |
+
tensorExample = RandomTensor.to(device)
|
|
|
15 |
|
16 |
return f"""
|
17 |
hostname: {platform.node()} {socket.gethostname()}
|
18 |
device: {device}
|
|
|
19 |
tensor: {tensorExample}
|
20 |
""";
|
21 |
|
22 |
@spaces.GPU
|
23 |
def gpu():
|
|
|
24 |
|
25 |
+
return sysinfo("cuda:0");
|
26 |
|
|
|
27 |
|
28 |
+
def nogpu():
|
29 |
+
|
30 |
+
return sysinfo("cpu");
|
31 |
|
32 |
|
33 |
|