Education logo

How to Install DOcplex on Compute Canada Cluster

Start using Compute Canada cluster with CPLEX for Mathematical Programming

By Soumen AttaPublished about a year ago 3 min read
Like
How to Install DOcplex on Compute Canada Cluster
Photo by Ali Tawfiq on Unsplash

In this tutorial, we will learn how to use DOcplex on Compute Canada cluster. For this, we need to install the IBM ILOG CPLEX Optimization Studio 20.1.0. The version may vary. Here, I am using the 20.1.0 version.

Step 1: Log in to Compute Canada cluster

We can use ssh to connect to the Compute Canada cluster. We can use the following command:

ssh [email protected]

Here, ‘username’ is your user name for the Compute Canada cluster. To use the Compute Canada cluster, you must have valid credentials.

Step 2: Download CPLEX

Next, we need to download CPLEX from the IBM website. Depending on the version you downloaded, the file name could be like this: ILOG_COS_20.10_LINUX_X86_64.bin

Step 3: Upload the CPLEX file to the cluster

We can upload the downloaded CPLEX binary file to the cluster using the following command:

scp ILOG_COS_20.10_LINUX_X86_64.bin [email protected]:/home/username/projects/def-mainuser/username

The above command is executed from a terminal where the binary file is located. You may also change the cluster path depending on your need. Note that depending on your situation, you need to modify 'username' and 'mainuser' according to your credentials.

Step 4: Make the binary file executable

Now, we have the binary file of CPLEX in the cluster. We need to make the binary file executable. We can do this as follows:

chmod +x ILOG_COS_20.10_LINUX_X86_64.bin

To read more tutorials from the author, please visit the link below.

Step 5: Execute the binary file to install CPLEX

Next, we need to execute the binary file to install CPLEX on the cluster as follows:

bash ./ILOG_COS_20.10_LINUX_X86_64.bin

Now, we just need to follow the instructions as shown in the installation terminal window.

Make sure to provide the installation directory as follows:

/home/username/projects/def-mainuser/satta/opt/ibm/ILOG/CPLEX_Studio201

This will install CPLEX.

Step 6: Install DOcplex

We want to use the Python API of CPLEX such as DOcplex. For this, we need to load the Python module first. Then we use the virtual environment and activate it to execute the setup python file. The commands are shown below:

module load python

virtualenv — no-download ENV

source ENV/bin/activate

python /home/username/projects/def-mainuser/satta/opt/ibm/ILOG/CPLEX_Studio201/python/setup.py install

This will also create a new directory “ENV” in the current directory. Finally, we execute the following command to install DOcplex, as follows:

pip install docplex

To exit from the virtual environment, we can use the following command:

deactivate

Step 7: Final configuration

To access CPLEX, we need to create a personal module. In order to find our installed CPLEX modules, we need to modify the configuration file $HOME/.bashrc so that it points to the root of this hierarchy, by adding the following line:

export MODULEPATH=$HOME/modulefiles:$MODULEPATH

Now, we need to create a directory structure in which we put the new CPLEX module, as follows:

mkdir -p $HOME/modulefiles/mycplex

We can use cd $HOME and ls commands to see that this directory structure has been created already.

Then, we need to go to the “mycplex” directory as follows:

cd modulefiles

cd mycplex

Now, we create a directory in the current directory as follows:

mkdir 20.1.0

The name of this directory is the same as the CPLEX version that we have just installed.

In this directory “20.1.0”, we need to upload a file. The file name is “cplex_module.sh”.

Note that depending on the CPLEX version that we have installed we need to change the lines corresponding to the variables “cplexversion” and “studio_root”. Download this file and open a terminal and use the following command to upload this downloaded file to the cluster:

scp cplex_module.sh [email protected]:/home/username/modulefiles/mycplex/20.1.0

Now, we are ready to use DOcplex on Compute Canada cluster.

For videos on technical content, you may visit the following YouTube channel:

collegehigh schoolinterviewstemstudentteacherhow to
Like

About the Creator

Soumen Atta

Dr. Soumen Atta, Ph.D. is an Assistant Professor in the Center for Information Technologies and Applied Mathematics, School of Engineering and Management at the University of Nova Gorica, Vipava, Slovenia. https://www.soumenatta.com/

Reader insights

Be the first to share your insights about this piece.

How does it work?

Add your insights

Comments

Soumen Atta is not accepting comments at the moment

Want to show your support? Send them a one-off tip.

Find us on social media

Miscellaneous links

  • Explore
  • Contact
  • Privacy Policy
  • Terms of Use
  • Support

© 2024 Creatd, Inc. All Rights Reserved.