WinBUGS

From UF HPC Wiki

Jump to: navigation, search

Contents

Instructions for installing and using WinBUGS/R2WinBUGS on the HPC

Because WINE is installed on the HPC, it is actually fairly straightforward to follow standard procedures to install and use WinBUGS (and R2WinBUGS). The only real challenges have to do with making sure that the graphical interface gets forwarded, or ignored, as appropriate.

Forwarding X11 graphics

The install process requires you to find a way to forward X11 graphics from the HPC to your desktop machine, because part of the installation process is GUI-based. If you use ssh on a machine with X11 running (i.e. Linux, MacOS), then ssh -X submit.hpc.ufl.edu should be sufficient. If you use another operating system, you will need to figure out a way to do this - I don't know how. Cygwin/X may work.

Installing WinBUGS itself

Quick, untested hack

Log in to submit.hpc.ufl.edu and copy the WINE setup directory to your home directory, i.e.

cp -r ~bolker/.wine ~

If you try this and it works, please update the page! If it works we will try moving the setup to a more standard system location.

From scratch

1. Log in to submit.hpc.ufl.edu

Following instructions on the BUGS web site

2. get the WinBUGS 1.4.3 installer:

wget http://www.mrc-bsu.cam.ac.uk/bugs/winbugs/WinBUGS14.exe

3. Move to test machine in order to have sufficient virtual memory for installation, with X11 forwarded:

ssh -X test05

4. run installer

wine WinBUGS14.exe

You will get some warning messages:

wine: created the configuration directory '/home/<user>/.wine'
  ALSA lib seq_hw.c:446:(snd_seq_hw_open) open /dev/snd/seq failed: No such file or directory
  Could not load Mozilla. HTML rendering will be disabled.
  err:wgl:has_opengl  glx_version is 1.2 and GLX_SGIX_fbconfig extension is unsupported. Expect problems.
wine: configuration in '/home/<user>/.wine' has been updated.
ALSA lib seq_hw.c:446:(snd_seq_hw_open) open /dev/snd/seq failed: No such file or directory

but these are apparently harmless.

5. get cumulative WinBUGS patch

wget
http://www.mrc-bsu.cam.ac.uk/bugs/winbugs/WinBUGS14_cumulative_patch_No3_06_08_07_RELEASE.txt

6. establish location of WinBUGS executable

export BUGS=".wine/drive_c/Program\ Files/WinBUGS14/WinBUGS14.exe"

7. run WinBUGS to apply patch

wine "$BUGS" # need quotes to deal with space in path

then, in GUI:

  File/Open/[Files of type "Text"]/[select WinBUGS14_cumulative_patch...]
  Tools/Decode/Decode All/["OK" to two queries]
 Quit

8. download key

wget http://www.mrc-bsu.cam.ac.uk/bugs/winbugs/WinBUGS14_immortality_key.txt
## sounds cool, doesn't it?

9. run WinBUGS to apply key

## [same as step #7 but select and decode the WinBUGS14_immortality_key.txt file that you just downloaded]

10. download R2WinBUGS and coda

wget http://cran.r-project.org/src/contrib/R2WinBUGS_2.1-13.tar.gz
wget http://cran.r-project.org/src/contrib/coda_0.13-4.tar.gz

(choose another, closer CRAN mirror?)

11. install them

R CMD INSTALL coda_0.13-4.tar.gz
R CMD INSTALL R2WinBUGS_2.1-13.tar.gz

Testing

The following code generates the test file from the Unix shell. If you enter the file in some other way, e.g. by cutting and pasting, make sure to remove the backslashes before the dollar signs.

cat >bugs-test.R <<EOF
library(R2WinBUGS)
## modified from ?bugs example

model.file <- system.file(package="R2WinBUGS", "model", "schools.txt")

     data(schools)

     J <- nrow(schools)
     y <- schools\$estimate  ## need backslash if run from shell!!!
     sigma.y <- schools\$sd  ## ditto
     data <- list ("J", "y", "sigma.y")
     inits <- function(){
         list(theta=rnorm(J, 0, 100), mu.theta=rnorm(1, 0, 100),
              sigma.theta=runif(1, 0, 100))
     }
     parameters <- c("theta", "mu.theta", "sigma.theta")

     schools.sim <- bugs(data, inits, parameters, model.file,
         n.chains=3, n.iter=5000)

     print(schools.sim)
     pdf("bugs-test.pdf")
     plot(schools.sim)
     dev.off()
[Ctrl-D]

Then run from the command line, with

R CMD BATCH bugs-test.R

(this will only work if you have forwarded X11 graphics).

If you have not/cannot forward X11 graphics, type

Xvfb :1 &
export DISPLAY=`hostname`:1.0

before running the above commands. The Xvfb call and the following line are designed to create a virtual screen (Xvfb stands for "X virtual frame buffer") and forward WinBUGS's graphics to oblivion.

You will get warnings

_XSERVTransmkdir: Owner of /tmp/.X11-unix should be set to root
Could not init font path element /usr/X11R6/lib/X11/fonts/TTF/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/CID/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/100dpi/, removing from list!

but these are harmless as far as I can tell.

Batch runs

Here is a script that will run the test in batch mode (it assumes that your test file is in a winbugs subdirectory within your home directory; adjust as necessary).

#PBS -l nodes=1:ppn=1:gige
#PBS -l walltime=0:10:00
cd winbugs
Xvfb :1 &
export DISPLAY=`hostname`:1.0
R CMD BATCH bugs-test.R

This can be run via qsub in the usual way.