Create new file
Browse files
app.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import numpy as np
|
2 |
+
from datasets import Dataset
|
3 |
+
from pynvml import *
|
4 |
+
|
5 |
+
|
6 |
+
def print_gpu_utilization():
|
7 |
+
nvmlInit()
|
8 |
+
handle = nvmlDeviceGetHandleByIndex(0)
|
9 |
+
info = nvmlDeviceGetMemoryInfo(handle)
|
10 |
+
print(f"GPU memory occupied: {info.used//1024**2} MB.")
|
11 |
+
|
12 |
+
|
13 |
+
def print_summary(result):
|
14 |
+
print(f"Time: {result.metrics['train_runtime']:.2f}")
|
15 |
+
print(f"Samples/second: {result.metrics['train_samples_per_second']:.2f}")
|
16 |
+
print_gpu_utilization()
|
17 |
+
|
18 |
+
seq_len, dataset_size = 512, 512
|
19 |
+
dummy_data = {
|
20 |
+
"input_ids": np.random.randint(100, 30000, (dataset_size, seq_len)),
|
21 |
+
"labels": np.random.randint(0, 1, (dataset_size)),
|
22 |
+
}
|
23 |
+
ds = Dataset.from_dict(dummy_data)
|
24 |
+
ds.set_format("pt")
|