Skip to content

Commit 0f6800c

Browse files
committed
update 3.28
1 parent 9052569 commit 0f6800c

4 files changed

Lines changed: 39 additions & 15 deletions

File tree

greaselm.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -522,18 +522,18 @@ def evaluate(args, has_test_split, devices, kg):
522522

523523

524524
def get_devices(use_cuda):
525-
"""Get the devices to put the data and the model based on whether to use GPUs and, if so, how many of them are available."""
526-
if torch.cuda.device_count() >= 2 and use_cuda:
527-
[device0, device1] = nv_usage.get_gpu_index(2)
528-
print("device0: {}, device1: {}".format(device0, device1))
529-
elif torch.cuda.device_count() == 1 and use_cuda:
530-
device0 = torch.device("cuda:0")
531-
device1 = torch.device("cuda:0")
532-
else:
533-
device0 = torch.device("cpu")
534-
device1 = torch.device("cpu")
535-
# device0 = torch.device("cuda:7")
536-
# device1 = torch.device("cuda:7")
525+
# """Get the devices to put the data and the model based on whether to use GPUs and, if so, how many of them are available."""
526+
# if torch.cuda.device_count() >= 2 and use_cuda:
527+
# [device0, device1] = nv_usage.get_gpu_index(2)
528+
# print("device0: {}, device1: {}".format(device0, device1))
529+
# elif torch.cuda.device_count() == 1 and use_cuda:
530+
# device0 = torch.device("cuda:0")
531+
# device1 = torch.device("cuda:0")
532+
# else:
533+
# device0 = torch.device("cpu")
534+
# device1 = torch.device("cpu")
535+
[device0] = nv_usage.get_gpu_index(1)
536+
device1 = device0
537537
return device0, device1
538538

539539

run_greaselm.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ else
3131
n_epochs=30
3232
max_epochs_before_stop=10
3333
ie_dim=400
34+
mbs=4
3435
fi
3536

3637
max_seq_len=100

test.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2023年03月27日
2+
./run_greaselm.sh obqa --data_dir data/ --emp True --use_wandb True
3+
./run_greaselm.sh obqa --data_dir data/ --emp False --use_wandb True
4+
5+
2023年03月28日
6+
./run_greaselm.sh csqa --data_dir data/ --emp True --use_wandb True
7+
./run_greaselm.sh csqa --data_dir data/ --emp False --use_wandb True
8+
9+
看obqa的k的值的影响
10+
./run_greaselm.sh obqa --data_dir data/ --emp True --use_wandb True -k 1
11+
./run_greaselm.sh obqa --data_dir data/ --emp False --use_wandb True -k 1
12+
13+
./run_greaselm.sh obqa --data_dir data/ --emp True --use_wandb True -k 3
14+
./run_greaselm.sh obqa --data_dir data/ --emp True --use_wandb True -k 7
15+
16+
17+
18+
19+
20+
21+

utils/nv_usage.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ def get_gpu_index(gpu_number):
1212
handle = pynvml.nvmlDeviceGetHandleByIndex(i)
1313
# Get the GPU utilization
1414
utilization = pynvml.nvmlDeviceGetUtilizationRates(handle).gpu
15-
if utilization == 0:
15+
meminfo = pynvml.nvmlDeviceGetMemoryInfo(handle)
16+
memrate = meminfo.used/meminfo.total
17+
if utilization == 0 and memrate < 0.05:
1618
gpu_index_list.append(i)
1719
if len(gpu_index_list) == gpu_number:
1820
return gpu_index_list
@@ -24,7 +26,7 @@ def get_gpu_index(gpu_number):
2426

2527

2628
if __name__ == "__main__":
27-
# print(get_gpu_index(1))
29+
print(get_gpu_index(1))
2830
# print(get_gpu_index(2))
29-
print(get_gpu_index(8))
31+
# print(get_gpu_index(8))
3032

0 commit comments

Comments
 (0)