Skip to content

Commit 7a736b6

Browse files
20260224 - install Mplus in container
1 parent 6083671 commit 7a736b6

File tree

1 file changed

+148
-2
lines changed

1 file changed

+148
-2
lines changed

hpc.qmd

Lines changed: 148 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,149 @@ Steps:
155155
```bash
156156
apptainer --version
157157
```
158+
1. Go to your home directory:
159+
```bash
160+
cd ~
161+
```
162+
1. View the files/folders in this directory:
163+
```bash
164+
ls
165+
```
166+
1. Create a `containers` folder (if you haven't already created it):
167+
```bash
168+
mkdir containers
169+
```
170+
1. Go to the `containers` folder:
171+
```bash
172+
cd containers
173+
```
174+
1. If you want to install `Mplus` in the container:
175+
- Copy the `Mplus` installer file for Linux into the build directory:
176+
```bash
177+
cp "/mnt/c/Users/itpetersen/Downloads/MplusLinux64.bin" \
178+
~/containers/
179+
```
180+
- Verify the `containers` folder has `MplusLinux64.bin`:
181+
```bash
182+
lss
183+
```
184+
- Generate the install properties file:
185+
```bash
186+
./MplusLinux64.bin -r ~/containers/mplus_install.properties
187+
```
188+
This will launch the installer and record your choices to the properties file.
189+
Go through the installation steps, and when done you'll have `mplus_install.properties` in your containers directory.
190+
- Edit the install path in the install properties file to `/opt/mplus` throughout:
191+
```bash
192+
nano mplus_install.properties
193+
```
194+
Here are the contents of my ` mplus_install.properties` file:
195+
```bash
196+
# Tue Feb 24 21:04:04 CST 2026
197+
# Replay feature output
198+
# ---------------------
199+
# This file was built by the Replay feature of InstallAnywhere.
200+
# It contains variables that were set by Panels, Consoles or Custom Code.
201+
#Choose Install Set
202+
#------------------
203+
CHOSEN_FEATURE_LIST=Application,Examples
204+
CHOSEN_INSTALL_FEATURE_LIST=Application,Examples
205+
CHOSEN_INSTALL_SET=Typical
206+
#Choose Install Folder
207+
#---------------------
208+
USER_INSTALL_DIR=/opt/mplus
209+
#Install
210+
#-------
211+
-fileOverwrite_/opt/mplus/uninstall/uninstall_mplus.lax=Yes
212+
-fileOverwrite_/opt/mplus/mplus=Yes
213+
-fileOverwrite_/opt/mplus/Documentation/Getting_Started.pdf=Yes
214+
-fileOverwrite_/opt/mplus/Documentation/Mplus_Users_Guide_v8.pdf=Yes
215+
-fileOverwrite_/opt/mplus/Documentation/Version_8.1_Language_Addendum.pdf=Yes
216+
-fileOverwrite_/opt/mplus/Documentation/Version_8.5_Language_Addendum.pdf=Yes
217+
```
158218
1. Create your `R` Container Definition File
159219
- Inside the Ubuntu terminal, run:
160220
```bash
161221
nano r_argon.def
162222
```
163-
- Paste this:
223+
- Paste this (for `Mplus` + `R` + `brms` + `cmdstanr` installation):
224+
```bash
225+
Bootstrap: docker
226+
From: rocker/r-ver:latest
227+
228+
%files
229+
MplusLinux64.bin /opt/MplusLinux64.bin
230+
mplus_install.properties /opt/mplus_install.properties
231+
232+
%post
233+
# Install system dependencies
234+
apt-get update && apt-get install -y \
235+
libcurl4-openssl-dev \
236+
libssl-dev \
237+
libxml2-dev \
238+
libgit2-dev \
239+
libfontconfig1-dev \
240+
libfreetype6-dev \
241+
libharfbuzz-dev \
242+
libfribidi-dev \
243+
libpng-dev \
244+
libtiff5-dev \
245+
libjpeg-dev \
246+
libglpk-dev \
247+
libgmp3-dev \
248+
libmpfr-dev \
249+
make \
250+
g++ \
251+
cmake \
252+
git \
253+
sudo
254+
255+
# Install Mplus
256+
chmod +x /opt/MplusLinux64.bin
257+
/opt/MplusLinux64.bin -i silent -f /opt/mplus_install.properties
258+
chmod -R 755 /opt/mplus
259+
260+
# Install core CRAN packages
261+
R -e "install.packages(c(
262+
'tidyverse',
263+
'data.table',
264+
'rstan',
265+
'brms',
266+
'mirt',
267+
'lavaan',
268+
'semTools',
269+
'MplusAutomation',
270+
'renv',
271+
'remotes'
272+
), repos='https://cloud.r-project.org')"
273+
274+
# Install cmdstanr
275+
R -e "install.packages('cmdstanr', repos = c('https://stan-dev.r-universe.dev','https://cloud.r-project.org'))"
276+
277+
# Install latest CmdStan into /opt/cmdstan
278+
mkdir -p /opt/cmdstan
279+
R -e "cmdstanr::install_cmdstan(cores = 2, dir='/opt/cmdstan')"
280+
281+
# Create a symlink 'latest' to the installed CmdStan version
282+
cd /opt/cmdstan
283+
ln -s cmdstan-* latest
284+
285+
# Enable threading for within-chain parallelization
286+
mkdir -p /root/.R
287+
echo 'CXXFLAGS += -DSTAN_THREADS' >> /root/.R/Makevars
288+
289+
# Install latest version of petersenlab package from GitHub
290+
R -e "remotes::install_github('DevPsyLab/petersenlab')"
291+
292+
%environment
293+
export R_LIBS_USER=/usr/local/lib/R/site-library
294+
export CMDSTAN=/opt/cmdstan/latest
295+
export PATH=/opt/mplus:$PATH
296+
297+
%runscript
298+
exec R "$@"
299+
```
300+
- Paste this (for `R` + `brms` + `cmdstanr` installation):
164301
```bash
165302
Bootstrap: docker
166303
From: rocker/r-ver:latest
@@ -197,6 +334,7 @@ Steps:
197334
'mirt',
198335
'lavaan',
199336
'semTools',
337+
'MplusAutomation',
200338
'renv',
201339
'remotes'
202340
), repos='https://cloud.r-project.org')"
@@ -253,10 +391,14 @@ Steps:
253391
```r
254392
q()
255393
```
394+
- If you attempted to install `Mplus`, verify the `Mplus` installation:
395+
```bash
396+
apptainer exec r_argon.sif /opt/mplus/mplus
397+
```
256398
1. Copy the Container to Your Computer
257399
- Inside the Ubuntu terminal, run (updating your path; this is equivalent to: `E:/Documents/OneDrive - University of Iowa/Research/Containers/`):
258400
```bash
259-
cp ~/apptainer-1.4.5/r_argon.sif "/mnt/e/Documents/OneDrive - University of Iowa/Research/Containers/"
401+
cp ~/containers/r_argon.sif "/mnt/e/Documents/OneDrive - University of Iowa/Research/Containers/"
260402
```
261403
1. Copy the Container to Argon
262404
- Use WinSCP to transfer the `.sif` file to Argon (updating your path): `/old_Users/itpetersen/Documents/Containers/`
@@ -280,6 +422,10 @@ Steps:
280422
```r
281423
q()
282424
```
425+
- If you attempted to install `Mplus`, verify the `Mplus` installation:
426+
```bash
427+
apptainer exec r_argon.sif /opt/mplus/mplus
428+
```
283429
1. Submit a Job Using the Container on Argon
284430
- e.g.:
285431
```bash

0 commit comments

Comments
 (0)