5 Special instructions for specific software

Last updated March 27, 2023

Some software require special steps for their installation or use. This chapter aims to document them.

5.1 Gurobi

The Gurobi package has some peculiarities involved in its installation including manually installing binaries and libraries to /opt/ and having to edit the PATH and LD_LIBRARY_PATH search paths as a result.

5.1.1 Use

On the Gurobi website, first create an account and make use of your product key, which is of the format XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX. Once everything is installed, each user will need to register their product key using the following code:

grbgetkey XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX

Note that the per-user registration only works on one machine at a time.

If the above code works, then nothing else needs to be done. The following section details how to install Gurbo and enable the above command on machines that do not yet have it.

5.1.2 Installation

5.1.2.1 Download Gurobi and upload to the server

From the Gurobi Optimizer download page, download the latest Gurobi Optimizer version for x64_Linux. For this guide, we will be installing version 9.5.1, so we will be downloading gurobi9.5.1_linux64.tar.gz

You can either download from your browser and then upload to one of the servers, or download the link directly to the server:

wget https://packages.gurobi.com/9.5/gurobi9.5.1_linux64.tar.gz

5.1.2.2 Decompress to /opt/

The /opt/ directory is where manually-installed static packages should be stored, i.e. those not created with makefiles. See man hier for more information.

tar xvf gurobi9.5.1_linux64.tar.gz
sudo mv gurobi951 /opt/

5.1.2.3 Enable for command-line users

Command-line shells like Bash will read default environment variables from /etc/environment before loading the systemwide and user .profile and .bash_profile scripts. We want to add the newly-installed Gurobi binaries and libraries to PATH and LD_LIBRARY_PATH, which are :-delimited lists of the program and shared library search paths, respectively.

Specifically, we want to add the following:

  • To PATH: /opt/gurobi951/linux64/bin (replace gurobi951 with whatever version of Gurobi you are installing)
  • To LD_LIBRARY_PATH: /opt/gurobi951/linux64/lib

PATH may already have something there, in which case only append :/opt/gurobi951/linux64/bin, as in the following:

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/opt/gurobi951/linux64/bin"

LD_LIBRARY_PATH is likely not there, so we can create a new line:

LD_LIBRARY_PATH="/usr/local/lib:/opt/gurobi951/linux64/lib"

We also need to define GUROBI_HOME as follows:

GUROBI_HOME=/opt/gurobi951/linux64

The final /etc/environment file should look something like this:

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/opt/gurobi951/linux64/bin"
LD_LIBRARY_PATH="/usr/local/lib:/opt/gurobi951/linux64/lib"
GUROBI_HOME=/opt/gurobi951/linux64

5.1.2.4 Enable for RStudio Server users

For whatever reason, RStudio Server does not respect /etc/environment. Therefore, we need to modify LD_LIBRARY_PATH manually. To do this, we just need to add the following line to /etc/rstudio/rserver.conf:

rsession-ld-library-path=/opt/gurobi951/linux64/lib/

After that, restart RStudio Server:

sudo systemctl restart rstudio-server

Verify that everything is OK:

systemctl status rstudio-server

5.1.2.5 Install the R package

Once the above is complete, we can install the R package itself. First, we need to see where R searches for packages using .libPaths:

> .libPaths()
[1] "/usr/local/lib/R/site-library" "/usr/lib/R/site-library"      
[3] "/usr/lib/R/library"           

From the above, it seems like /usr/lib/R/site-library might be a good choice. Now, we can install Gurobi and its dependency slam:

# Be sure to run as root
install.packages("slam", repos = "https://cran.r-project.org", lib = "/usr/lib/R/site-library")
install.packages("/opt/gurobi951/linux64/R/gurobi_9.5-1_R_4.1.1.tar.gz", repos = NULL, lib = "/usr/lib/R/site-library")

Confirm that it works:

> library(gurobi)
Loading required package: slam
Warning message:
package ‘gurobi’ was built under R version 4.1.1 

5.2 fbkmr

fbkmr does not exist on CRAN yet and must be installed manually. Ensure that first gurobi is installed (see the section on Gurobi). To decompress the file, run tar -xvf /path/to/fbkmr_0.1.0.tar.gz (or whatever the tarball is named).

5.2.1 Installing dependencies

The fbkmr package comes with a file called NAMESPACE. By running the following command we can extract a list of all imported packages and print it as an R vector:

LIBRARIES=$(
    grep import fbkmr/NAMESPACE |
        tr -c "[:alnum:]\n" " " |
        awk '{print $2}' |
        sort |
        uniq |
        tr "\n" " " |
        head -c -2
)
echo "TO_INSTALL <- c(\"$(sed 's/ /", "/g' <<< "$LIBRARIES")\")"

After pasting this into R, we can then install these libraries using the following code:

invisible(lapply(
    TO_INSTALL,
    function(package) if (!require(package, character.only = TRUE)) install.packages(
        package,
        lib = "/usr/local/lib/R/site-library", # may differ based on machine; use `.libPaths()`
        # lib = "/opt/R/4.1.1/lib/R/library", # for example
        repos = "https://cran.r-project.org"
    )
))

5.2.2 Installing fbkmr

Now, we can install fbkmr using the usual code:

invisible(install.packages(
    "./fbkmr/",
    lib = "/usr/local/lib/R/site-library", # or what is specified by .libPaths()
    # lib = "/opt/R/4.1.1/lib/R/library", # for example
    repos = NULL,
    type = "source"
))

5.3 RQPD

RQPD cannot be installed from CRAN and needs to be installed manually.

5.3.1 Clone the RQPD Subversion repository

The RQPD source code is available on R-Forge in a Subversion repository that we can clone:

svn checkout svn://scm.r-forge.r-project.org/svnroot/rqpd/

5.3.2 Install

From here, we can install RQPD. We also need to install all dependencies manually since we are not using CRAN:

# Be sure to run the following as root

# Install missing dependencies, if any
lapply(
    c("stats", "quantreg", "Formula", "Matrix", "MatrixModels", "SparseM"),
    function(package) {
        if (!require(package)) {
            install.packages(
                package,
                lib = "/usr/lib/R/library",
                repos = "https://cran.r-project.org"
            )
        }
    }
)

# Install RQPD from cloned source
install.packages(
    "./rqpd/pkg/",
    lib = "/usr/lib/R/library", # or what is specified by .libPaths()
    repos = NULL,
    type = "source"
)

Verify that it works:

> library(rqpd)
Loading required package: quantreg
Loading required package: SparseM

Attaching package: ‘SparseM’

The following object is masked from ‘package:base’:

    backsolve

Loading required package: Matrix
Loading required package: MatrixModels
Loading required package: Formula