demo 1
Browse files
app.py
CHANGED
|
@@ -4,9 +4,21 @@ import platform
|
|
| 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 |
@torch.inference_mode()
|
| 12 |
def sysinfo():
|
|
@@ -16,6 +28,7 @@ def sysinfo():
|
|
| 16 |
return f"""
|
| 17 |
hostname: {platform.node()} {socket.gethostname()}
|
| 18 |
device: {device}
|
|
|
|
| 19 |
tensor: {tensorExample}
|
| 20 |
""";
|
| 21 |
|
|
|
|
| 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 |
+
def device():
|
| 19 |
+
return next(model.parameters()).device
|
| 20 |
+
|
| 21 |
+
model = SimpleModel().to(device);
|
| 22 |
|
| 23 |
@torch.inference_mode()
|
| 24 |
def sysinfo():
|
|
|
|
| 28 |
return f"""
|
| 29 |
hostname: {platform.node()} {socket.gethostname()}
|
| 30 |
device: {device}
|
| 31 |
+
model device: {model.device}
|
| 32 |
tensor: {tensorExample}
|
| 33 |
""";
|
| 34 |
|