The file I used was Anaconda3-2020.11-Linux-x86_64.sh from https://repo.anaconda.com/archive/
wget https://repo.anaconda.com/archive/Anaconda3-2020.11-Linux-x86_64.sh
bash Anaconda3-2020.11-Linux-x86_64.sh
I tried lots of older and newer versions of python but 3.7.0 is the one that worked for me. The patchelf is necessary for the next step.
conda create --name py37
conda activate py37
conda install -c anaconda pip python=3.7.0 --yes
conda install patchelf -c conda-forge --yes
conda install pytorch==1.10.2 -c pytorch
At this point, python should work but importing torch should not.
This is solely derived from: https://gist.github.com/michaelchughes/85287f1c6f6440c060c3d86b4e7d764b
mkdir ~/my_libc_env
cd ~/my_libc_env
# Get libc files (URL verified by AS on 2022/02/24)
wget https://launchpadlibrarian.net/353523729/libc6_2.23-0ubuntu10_amd64.deb
wget http://launchpadlibrarian.net/353523714/libc6-dev_2.23-0ubuntu10_amd64.deb
# Unpack files into current directory (will create usr/ and lib/ and lib64/ folders)
ar p libc6_2.23-0ubuntu10_amd64.deb data.tar.xz | tar xvJ
ar p libc6-dev_2.23-0ubuntu10_amd64.deb data.tar.xz | tar xvJ
# Get libstdc++ (URL verified by AS on 2022/02/24)
wget https://yum.oracle.com/repo/OracleLinux/OL6/0/base/x86_64/getPackage/libstdc++-devel-4.4.4-13.el6.x86_64.rpm
# Unpack into current directory (will add content to lib/ and lib64/ folders)
rpm2cpio libstdc++6-4.8.2-3.2.mga4.x86_64.rpm | cpio -idmv
I've modified the original slightly to work. This broadly works in the following manner:
- Create
GLIBC_LD_PATH
environment variable - Finds the current python path and stores it to
python_exe
(this expects you to be running it in a conda env) - Finds the
lib
folder in the conda environment and stores it toCONDA_ENV_LIB
variable - Copies the original python to a file named 'python_backup' in the same folder
- Creates the
rpath
variable (run-time path variable) which first searches in our customGLIBC_PATH
first - 'Patches' python file to hard-code these paths into the python binary
bash rewrite_python_exe_glibc_with_patchelf.sh
At this point, running python and importing torch still didn't work for me (if it did for you, GREAT! - you don't have to do the next step).
You're better off adding this to your .bashrc
file or re-create the alias at login (AFTER activating the conda environment)
conda activate py37
alias tpython="LD_LIBRARY_PATH=$HOME/my_libc_env/lib64 `which python`"
conda install numpy scipy pandas matplotlib --yes
conda install -c conda-forge scikit-learn bayesian-optimization --yes