Skip to content

Commit 0a1bf2e

Browse files
committed
more logs
1 parent b6f2c9e commit 0a1bf2e

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

paper/benchmark/benchmark.R

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ library(batchtools)
22
library(mlr3misc)
33

44
setup = function(reg_path, python_path, work_dir) {
5+
6+
print_setup_info(reg_path, python_path, work_dir)
7+
58
reg = makeExperimentRegistry(
69
file.dir = reg_path,
710
work.dir = work_dir,
@@ -69,6 +72,7 @@ setup = function(reg_path, python_path, work_dir) {
6972
})
7073

7174
addAlgorithm("rtorch", fun = function(instance, job, opt_type, jit, ...) {
75+
print
7276
assert_choice(opt_type, c("standard", "ignite"))
7377
if (opt_type == "ignite") {
7478
instance$optimizer = paste0("ignite_", instance$optimizer)
@@ -94,3 +98,29 @@ REPLS = 10L
9498
EPOCHS = 20L
9599
N = 2000L
96100
P = 1000L
101+
102+
print_setup_info = function(reg_path, python_path, work_dir) {
103+
cat("Session Info:\n")
104+
print(sessionInfo())
105+
cat("Library Paths:\n")
106+
for (path in .libPaths()) {
107+
cat(" -", path, "\n")
108+
}
109+
cat("Working Directory:", getwd(), "\n")
110+
111+
cat("Subfolders of working directory:\n")
112+
for (folder in list.files(work_dir)) {
113+
cat(" -", folder, "\n")
114+
}
115+
116+
# Function arguments
117+
cat("--- FUNCTION ARGUMENTS ---\n")
118+
cat(" Registry Path:", reg_path, "\n")
119+
cat(" Python Path:", python_path, " (", if (file.exists(python_path)) "exists" else "does not exist", ")\n")
120+
cat(" Work Directory:", work_dir, "\n\n")
121+
cat("Cuda is available:", torch::cuda_is_available(), "\n")
122+
cat("Torch install path:", torch::install_path(), "\n")
123+
reticulate::use_python(python_path, required = TRUE)
124+
reticulate::source_python(here::here("benchmark", "time_pytorch.py"))
125+
print(reticulate::py_config())
126+
}

paper/benchmark/time_pytorch.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@
66

77
# 3. Define the timing function
88
def time_pytorch(epochs, batch_size, n_layers, latent, n, p, device, seed, optimizer, jit):
9+
print(f"epochs: {epochs}")
10+
print(f"batch_size: {batch_size}")
11+
print(f"n_layers: {n_layers}")
12+
print(f"latent: {latent}")
13+
print(f"n: {n}")
14+
print(f"p: {p}")
15+
print(f"device: {device}")
16+
print(f"seed: {seed}")
17+
print(f"optimizer: {optimizer}")
18+
print(f"jit: {jit}")
19+
920
torch.manual_seed(seed)
1021
torch.set_num_threads(1)
1122
# convert latentn, n_layers to int

paper/benchmark/time_rtorch.R

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ time_rtorch = function(epochs, batch_size, n_layers, latent, n, p, device, jit,
44
torch_set_num_threads(1)
55
torch_manual_seed(seed)
66

7+
cat("epochs: ", epochs, "\n")
8+
cat("batch_size: ", batch_size, "\n")
9+
cat("n_layers: ", n_layers, "\n")
10+
cat("latent: ", latent, "\n")
11+
cat("n: ", n, "\n")
12+
cat("p: ", p, "\n")
13+
cat("device: ", device, "\n")
14+
cat("jit: ", jit, "\n")
15+
cat("seed: ", seed, "\n")
16+
cat("optimizer: ", optimizer, "\n")
17+
cat("mlr3torch: ", mlr3torch, "\n")
18+
719
lr = 0.0001
820

921
make_network = function(p, latent, n_layers) {

0 commit comments

Comments
 (0)