Skip to content

Instantly share code, notes, and snippets.

@zouguangxian
Last active May 22, 2022 01:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zouguangxian/31856f63fe2ac1bad11f404728dfb305 to your computer and use it in GitHub Desktop.
Save zouguangxian/31856f63fe2ac1bad11f404728dfb305 to your computer and use it in GitHub Desktop.
Fixes for GLIBC errors when installing jupyter on CentOS 6

Goal

Install jupyter on conda environment.

Background

Install python 3.8 on CentOS 6 via conda, and python has a dependency on GLIBC 2.17. to resolve this issue, GLIBC 2.17 should be compiled and installed, and use patchelf to modify dynamic loader and rpath of python.

Step 1: compile and install patchelf

C++17 is required for building patchelf 0.14. so 0.13.1 is choosed for compatibility.

wget https://github.com/NixOS/patchelf/archive/refs/tags/0.13.1.tar.gz
tar zxvf 0.13.1.tar.gz
cd patchelf-0.13.1
./bootstrap.sh
cd ..
mkdir build/patchelf
cd build/patchelf
../../patchelf-0.13.1/configure --prefix=$HOME/opt
make -j4
make install

Step 2: compile and install glibc

wget http://ftp.gnu.org/gnu/glibc/glibc-2.17.tar.gz
tar zxvf glibc-2.17.tar.gz
mkdir build/glibc
cd build/glibc
../../glibc-2.17/configure --prefix=$HOME/opt/glibc
make -j4
make install

Step 3: create environment with conda

conda create --name jupyter python=3.8

Step 4: patch python

conda activate jupyter
which python | grep -q '\.conda.*envs'  && ~/opt/bin/patchelf --set-interpreter $HOME/opt/glibc/lib/ld-2.17.so --set-rpath $HOME/opt/glibc/lib/:`which python | sed 's,/bin/python,/lib,g'`:/usr/lib64:/lib64:/lib `which python`

Step 5: install jupyter

conda activate jupyter
conda install -c conda-forge notebook
conda install -c conda-forge nb_conda_kernels
conda install -c conda-forge jupyter_contrib_nbextensions

References

Fixes for GLIBC errors when installing tensorflow or pytorch on older Red Hat or CentOS cluster environments

Installing TensorFlow on systems with glibc < 2.17

Multiple glibc libraries on a single host

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