Install TensorFlow with GPU support on Red Hat Linux

I had the chance to play with Tensorflow, a high performance machine learning framework/library originally developed by Google. These are my installation notes.

I am working on the system with Red Hat Linux

cat /etc/redhat-release
# Output: Red Hat Enterprise Linux Server release 7.4 (Maipo)

The easiest option to install Tensorflow seems to be using Anaconda. I used the more lightweight version of Anaconda called Miniconda. To download and install Miniconda 3:


Accept the license, enter your preferred install location, then say ‘yes’ to prepend the install location to your $PATH environment variable.

Once conda has been installed, now it’s time to install Tensorflow. The instructions come from this Tensorflow page, but adapted a little bit for my purpose. I just downloaded the tensorflow-gpu package that is provided by Anaconda.

conda update conda
conda create -n tensorflow_conda pip python=2.7
source activate tensorflow_conda
conda install -c anaconda cudatoolkit=9.0
conda install -c anaconda tensorflow-gpu

To validate the installation, try the following in python:

import tensorflow as tf
# Output: 1.8.0
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
# Output: Hello, TensorFlow!

When you leave, you can call source deactivate to exit the conda environment. To get back again, call source activate tensorflow_conda.

Note that when the conda environment isactivated, the $PATH is prepended with <your-install-location>/envs/tensorflow_conda/bin. In some cases, you might also want to prepend $LD_LIBRARY_PATH with <your-install-location>/envs/tensorflow_conda/lib. This will help tensorflow find and import all the necessary CUDA libraries such as,, and whatnot.

Finally, to also install other machine learning-related libraries:

pip install -U pip
pip install keras sklearn matplotlib jupyter

In case you want to remove the environment:

conda remove --name tensorflow_conda --all

CMSSW and Git

Useful links about Git:

If you see this error message:

Permission denied (publickey)
fatal : Could not read from remote repository

Please make sure you have the correct access rights
and the repository exists

You are probably trying to download/clone/pull from a repository using an address that looks like<username>/<repo>.git. If you just want the read-only access to the repo (not committing any changes back), you can simply change the address to<username>/<repo>.git. And you are done. :relaxed:

However, if you want to be a collaborator and get the read & write access to the repo, you have to use the<username>/<repo>.git address. (Certain CMSSW tools might force you to use it even if you don’t need the read & write access). In this case, you have to follow the instructions here:

In particular, make sure you register in github your ssh key. It means that you must do the following:

  1. Create a GitHub account.
  2. Generate a SSH key.
    • Typically it’s saved as ~/.ssh/id_rsa
  3. Associate the SSH key to your GitHub account.
  4. Activate the SSH key every time you connect to GitHub.
    • On Linux, call eval "$(ssh-agent -s)" followed by ssh-add ~/.ssh/id_rsa


CMSSW has moved to GitHub in Summer 2013. The read-only CVS repository is maintained at

CMSSW GlobalTag

CMS Global Tags for Conditions Data:

How to change it?

from Configuration.AlCa.GlobalTag import GlobalTag
process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_mc')

Build with SCRAM

SCRAM is the tool used to compile/build CMSSW projects. Every CMS user should be familiar with scram b which is basically like make. Here are a few tips beyond the basic scram b:

  • scram b -j4 let you compile with 4 cores (like make -j4).

  • scram b clean let you do a clean build (like make clean).

  • scram b distclean && scram b vclean && scram b clean let you do a really clean build.

  • scram b USER_CXXFLAGS="-g -DDEBUG" let you make a debug build.

For the documentation for SCRAM, see: