Skip to content

Commit b6f2c9e

Browse files
committed
set seed, better readme, better errors, better .Rprofile
1 parent fe16bf3 commit b6f2c9e

File tree

7 files changed

+29
-6
lines changed

7 files changed

+29
-6
lines changed

paper/.Rprofile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
if(!file.exists("/.dockerenv")) {
2+
source("renv/activate.R")
3+
}

paper/README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,14 @@ Also note that it's important to have enough RAM, otherwise the benchmarks will
8282
However, there are many other factors, such as the exact hardware that make it generally difficult to reproduce the runtime results.
8383

8484
To run the benchmarks locally, ensure that you are in the `paper` directory.
85+
There are three scripts:
86+
87+
* `paper/benchmark/linux-gpu.R`, which creates the folder `paper/benchmark/registry-linux-gpu`
88+
* `paper/benchmark/linux-cpu.R`, which creates the folder `paper/benchmark/registry-linux-cpu`
89+
* `paper/benchmark/linux-gpu-optimizer.R`, which creates the folder `paper/benchmark/registry-linux-gpu-optimizer`
90+
91+
If one of the folders already exists and you want to re-run the benchmarks, you need to delete or move the folder.
92+
8593
To run the GPU benchmarks (using the CUDA docker image) on linux, run:
8694

8795
```bash
@@ -100,7 +108,7 @@ To run the benchmark that compares "ignite" with standard optimizers (using the
100108
Rscript benchmark/linux-gpu-optimizer.R
101109
```
102110

103-
The results are stored in:
111+
The postprocessd results are stored in:
104112

105113
* `paper/benchmark/result-linux-gpu.rds`
106114
* `paper/benchmark/result-linux-cpu.rds`

paper/benchmark/benchmark.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ setup = function(reg_path, python_path, work_dir) {
55
reg = makeExperimentRegistry(
66
file.dir = reg_path,
77
work.dir = work_dir,
8-
packages = "checkmate"
8+
packages = "checkmate",
9+
seed = 123
910
)
1011
reg$cluster.functions = makeClusterFunctionsInteractive()
1112

paper/benchmark/linux-cpu.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ library(here)
22

33
source(here("benchmark", "benchmark.R"))
44

5+
set.seed(42)
6+
57
# Change this when not running this in the docker image
68
# Below is the correct python path for the CPU docker image.
79
PYTHON_PATH = "/opt/venv/bin/python"

paper/benchmark/linux-gpu-optimizer.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,16 @@ library(here)
22

33
source(here("benchmark", "benchmark.R"))
44

5+
set.seed(43)
6+
57
# Change this when not running this in the docker image
68
# Below is the correct python path for the CUDA docker image
79
PYTHON_PATH = "/usr/bin/python3"
810

11+
if (!torch::cuda_is_available()) {
12+
stop("Cuda is not available for R-torch, please use the correct docker image.")
13+
}
14+
915
problem_design = expand.grid(
1016
list(
1117
n = N,

paper/benchmark/linux-gpu.R

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,16 @@ library(here)
22

33
source(here("benchmark", "benchmark.R"))
44

5+
set.seed(44)
6+
57
# Change this when not running this in the docker image
68
# Below is the correct python path for the CUDA docker image
79
PYTHON_PATH = "/usr/bin/python3"
810

11+
if (!torch::cuda_is_available()) {
12+
stop("Cuda is not available for R-torch, please use the correct docker image.")
13+
}
14+
915
problem_design = expand.grid(
1016
list(
1117
n = N,
@@ -21,7 +27,7 @@ problem_design = expand.grid(
2127
)
2228

2329
if (dir.exists(here("benchmark", "registry-linux-gpu"))) {
24-
stop("Registry already exists. Delete it to run the benchmark again.")
30+
stop("Registry benchmark/registry-linux-gpu already exists. Delete it to run the benchmark again.")
2531
}
2632

2733
setup(

paper/benchmark/time_rtorch.R

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
time_rtorch = function(epochs, batch_size, n_layers, latent, n, p, device, jit, seed, optimizer, mlr3torch = FALSE) {
22
library(mlr3torch)
33
library(torch)
4-
mlr3pipelines::po
5-
mlr3torch::LearnerTorch
6-
mlr3::lrn
74
torch_set_num_threads(1)
85
torch_manual_seed(seed)
96

0 commit comments

Comments
 (0)