Skip to content

Instantly share code, notes, and snippets.

@WPettersson
Last active January 7, 2019 05:12
Show Gist options
  • Save WPettersson/badca00c15afe75eb48a13577d143641 to your computer and use it in GitHub Desktop.
Save WPettersson/badca00c15afe75eb48a13577d143641 to your computer and use it in GitHub Desktop.

Installing CPLEX

Step 0 - Decide where you want things

You'll be installing everything into your home directory, so you might want to keep it organised. First you want to find out what your home directory is, so run cd with no directory specif ied to move to your home directory, and then run pwd to see your home directory. Mine is /home/595/wep595.

Now choose a place to install cplex. I suggest installing cplex into ~/opt/ibm/ILOG/CPLEX_Studio1263 and the python bindings into ~/cplex. Note that ~ is a common unix shortcut for your home directory, so for me I will install cplex into /home/595/wep595/opt/ibm/ILOG/CPLEX_Studio1263. From here on, I will refer to the cplex directory as $CPLEX and the python directory as $PYTHON.

Step 0.5 - Load python modules if on raijin

Run module load python3

Step 1 - Set up Python virtual environment

Run pyvenv $PYTHON. N.B. If you have multiple versions of python installed, say 2.7 and 3.4, you can specify the version of python to use by running pyvenv-3.4 $PYTHON or similar. Recall that $PYTHON is the place you decided to install the python bindings

Step 2 - Activate the Python environment

cd $PYTHON and then run source bin/activate.

Step 3 - Install cplex

Run sh cplex_studio1263.linux-x86-64.bin (you might need to change the version numbers or path). Select your preferred locale, accept the warning and license agreement. After accepting the license agreement, the installer will ask you for an installation directory. Enter $CPLEX as determined in Step 0. Note that you cannot use the ~ shortcut here, enter the full path (i.e. with your own home directory fully written out). Ensure the directory has been entered correctly, then continue with installation.

Step 3.5 - Remove documentation (optional)

Cplex takes up close to 2GB of drive space, and that is your limit on NCI. To save some space, I remove the documentation folder by running cd $CPLEX/; rm -r doc.

Step 4 - Install Python bindings

cd $CPLEX/cplex/python/python3.4/x86-64_linux (replace 3.4 with 2.6 if you want the 2.6 bindings), then run python3 setup.py install. N.B. Since you have activated a python virtual environment, python already knows where to install the bindings.

Using CPLEX

With C/C++

Includes are in $CPLEX/cplex/include and static librarys are in $CPLEX/cplex/lib/x86-64_linux/static_pic. Compile against these and your resulting executable should run fine in jobs without any extra requirements.

With Python

Any jobs you want to submit using the Python interface must first load the python3 module, and then activate your virtual environment. For instance

module load python3
source $PYTHON/bin/activate
python3 /path/to/script.py

Replace $PYTHON with the directory you installed the bindings to in Step 4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment