umxCloud: Run umx / OpenMx models on ephemeral Hetzner Cloud multicore...

View source: R/umxCloud.R

umxCloudR Documentation

Run umx / OpenMx models on ephemeral Hetzner Cloud multicore nodes

Description

umxCloud provisions an on-demand Linux server on Hetzner Cloud, transfers a model over SSH, runs optimization inside a Docker container, returns the fitted model, and (by default) destroys the server so billing stops when idle.

Usage

umxCloud(
  model,
  apiToken = Sys.getenv("HETZNER_API_TOKEN"),
  serverType = "cpx31",
  dockerImage = "rocker/r-ver:4.4.2",
  location = "fsn1",
  autoDestroy = TRUE,
  tryHard = c("no", "yes", "ordinal", "search"),
  maxBootMinutes = 15,
  keepOnError = FALSE,
  verbose = TRUE
)

Arguments

model

An MxModel (e.g. from umxACE(..., autoRun = FALSE)) with data attached.

apiToken

Hetzner API token. Default Sys.getenv("HETZNER_API_TOKEN").

serverType

Hetzner server type. Default "cpx31" (cheap smoke test). Use "ccx33", "ccx43", "ccx53", or "ccx63" for dedicated cores.

dockerImage

Docker image with R. Default public "rocker/r-ver:4.4.2". OpenMx and umx are installed inside the container on first use if missing.

location

Datacenter: "fsn1", "nbg1", "hel1", "ash", etc. Default "fsn1".

autoDestroy

Destroy server and Hetzner SSH key on exit? Default TRUE.

tryHard

Passed to remote umxRun. Default "no" for smoke tests.

maxBootMinutes

Max minutes to wait for SSH + Docker readiness. Default 15.

keepOnError

If TRUE, do not destroy the server when the run fails (for SSH debug). Default FALSE. Prints host IP when keeping the server.

verbose

Print progress messages? Default TRUE.

Details

Designed for small labs that need more cores than a laptop for heavy OpenMx/umx fits (long tryHard, large raw FIML, bootstrap grids), without keeping a permanent server.

First smoke test: use a cheap shared type such as serverType = "cpx31". First run often takes 8-20 minutes (VM boot, Docker install, image pull, install OpenMx/umx from binaries). After plumbing works, switch to dedicated ccx* types for real multicore jobs.

The model must already contain its data (mxData / umx builders with data attached). There is no remote data= argument.

Value

Fitted MxModel from the remote run.

Step-by-Step Setup

  1. Create a Hetzner Cloud account at https://console.hetzner.com/ (complete verification; avoid VPN during signup if fraud checks fail).

  2. Project -> Security -> API Tokens -> Generate (Read & Write). Copy the token.

  3. Store it in .Renviron (never commit the token):

        usethis::edit_r_environ()
        # HETZNER_API_TOKEN="..."
        

    Restart R. Confirm with nzchar(Sys.getenv("HETZNER_API_TOKEN")).

  4. Install optional packages once: install.packages(c("httr2", "ssh")).

Cost notes (approximate, check Hetzner for current prices)

  • Smoke test: cpx31 / similar shared – a few cents per short trial.

  • ccx33 (8 dedicated cores): ~EUR0.22 / hour.

  • ccx53 (32 dedicated cores): ~EUR0.86 / hour.

  • ccx63 (64 dedicated cores): ~EUR1.60 / hour.

Default autoDestroy = TRUE deletes the server and temporary SSH key on exit (including errors), unless keepOnError = TRUE leaves the box for debugging.

See Also

umxRun, umxACE

Other Twin Modeling Functions: power.ACE.test(), umx, umxACE(), umxACE_DE(), umxACE_GLM(), umxACEcov(), umxACEv(), umxCP(), umxDiffMZ(), umxDiscTwin(), umxDoC(), umxDoCp(), umxGxE(), umxGxE_window(), umxGxEbiv(), umxIP(), umxMRDoC(), umxReduce(), umxReduceACE(), umxReduceGxE(), umxRotate.MxModelCP(), umxSexLim(), umxSimplex(), umxSummarizeTwinData(), umxSummaryACE(), umxSummaryACE_GLM(), umxSummaryACEv(), umxSummaryDoC(), umxSummaryGxEbiv(), umxSummarySexLim(), umxSummarySimplex(), umxTwinMaker(), umx_make_double_entry_data()

Examples

## Not run: 
# Requires HETZNER_API_TOKEN in .Renviron and packages httr2, ssh
library(umx)
data(twinData)
mz = twinData[twinData$zygosity == "MZFF", ][1:200, ]
dz = twinData[twinData$zygosity == "DZFF", ][1:200, ]
m0 = umxACE(
  selDVs = c("bmi1", "bmi2"),
  mzData = mz, dzData = dz, sep = "",
  autoRun = FALSE
)
# Cheap first try (~cents). Watch Hetzner console: server should appear then vanish.
m1 = umxCloud(m0, serverType = "cpx31", tryHard = "no")
summary(m1)

# After plumbing works, use dedicated cores for heavy jobs:
# m1 = umxCloud(m0, serverType = "ccx53", tryHard = "yes")

## End(Not run)

umx documentation built on Oct. 11, 2026, 5:07 p.m.