TensorFlow uses on AVX instruction-void CPU may be as good as that on more modern CPU
While a TensorFlow version newer than 1.5 requires very pricey CPU capable of performing AVX instruction, the TensorFlow version 1.5 can still work on a CPU incapable of performing AVX instruction
Now the point is; this TensorFlow can only be utilized by using Python version 3.6 or older only, which is now difficult to build due to incompatibilility or interfacing incorrectness between it and current OS mainstream packages, leading to build failures. This because of its EOL (end-of-life) as stated in its official page:
Warning: Python 3.6.0 reached end-of-life on 2021-12-23. It is no longer supported and does not receive security updates. We recommend upgrading to the latest Python release
So here and now, this is to fix and revive the Python 3.6 project to have this Python correctly built and be made use for old TensorFlow version 1.5
It requires, as a dependency, certain openSSL version
-
Get openSSl 1.1.1
https://github.com/openssl/openssl/releases/download/OpenSSL_1_1_1w/openssl-1.1.1w.tar.gz -
Prepare a location, write down or remember well its path, later this'd be the same path where the Python tar must be extracted to
Extract openssl tar in this path as a directory, make sure its owner is the user with 755 permission entirely -
So the path would gather directory:
openssl-1.1.1wsourceopenssl-1.1.1w.bin(a renamed/suffixed of previous one automatically created, shown below)Python-3.6.15source
-
Enter into openssl-1.1.1w source directory and build
cd openssl-1.1.1w && ./config -march=native --prefix=$PWD.bin && make -j && make installNotice
$PWD.bin. This suffixes it asopenssl-1.1.1w.binwhich will be automatically created duringmake installexecution -
Now download Python 3.6.15 project source from its download page
https://www.python.org/ftp/python/3.6.15
Find and click the download link, or click:
https://www.python.org/ftp/python/3.6.15/Python-3.6.15.tar.xz
Extract it as directory in the path just explained above, ensure the owner is the user with 755 permission entirely -
Enter it and edit file
Modules/mathmodule.cGo down to the beginning of functionsinpi(double x)at line 69 or so, and insert this preprocessor code line and its closing one:#if !defined(__GLIBC__) || __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 38) #endifSo this:
69 static double 70 sinpi( double x) { ... ... 103 }become:
69 #if !defined(__GLIBC__) || __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 38) 70 static double 71 sinpi( double x) 72 { ... 103 } 104 #endif -
Build it using this command line that would compile it against the newly created openSSL static library, and should skip useless PGO-build module tests
it will install in/usr/bin./configure --without-ensurepip --prefix=/usr CFLAGS='-march=native -O3' CPPFLAGS=-I../openssl-1.1.1w.bin/include LDFLAGS='-L../openssl-1.1.1w.bin/lib' LIBS='-lssl -lcrypto -ldl -lpthread -lz' && make PROFILE_TASK='-m test.regrtest --pgo -x test_asyncio test_buffer test_concurrent_futures test_compileall test_decimal test_httplib test_io test_lib2to3 test_pickle test_readline test_signal test_socket test_tarfile test_trace test_venv test_weakref' profile-opt -j && strip python && sudo make install -
Verify the one there
./python --version` && ./python -c 'import ssl; print(ssl.OPENSSL_VERSION)'Python 3.6.15
OpenSSL 1.1.1w 11 Sep 2023 -
Please note. IMPORTANT!
Simply inspect the python related filesls -l /usr/bin/pyt*lrwxrwxrwx 1 root root 19 Apr 5 09:33 /usr/bin/python -> /usr/bin/python3.14
lrwxrwxrwx 1 root root 9 Apr 5 09:30 /usr/bin/python3 -> python3.6
-rwxr-xr-x 1 root root 14384 Feb 15 07:49 /usr/bin/python3.14
-rwxr-xr-x 1 root root 3385 Feb 15 07:49 /usr/bin/python3.14-config
-rwxr-xr-x 2 root root 3090792 Apr 5 12:23 /usr/bin/python3.6
lrwxrwxrwx 1 root root 17 Apr 5 09:30 /usr/bin/python3.6-config -> python3.6m-configSince
makeinstall location set by--prefix=/usrshown in CL above will put python3.6.15 binary in/usr/bin, the installation may possibly replace system-widepythonlink with another pointing to it. Since most system tools using this main/system-wide python latest version, invoking it will mistakenly run this one just installed. On that case, must link it backsudo ln -sf /usr/bin/{python3.14, python}` sudo ln -sf /usr/bin/python{3.14,}-configCorrect the actual version number accordingly
-
Next is to have a Python 3.6 environment, say, it's
TensorFlow1.5in home directory:python3.6 -m venv ~/TensorFlow1.5 -
Enter it and Install
pipof its version and verify. ~/TensorFlow1.5/activate` curl -O https://bootstrap.pypa.io/pip/3.6/get-pip.py && python get-pip.py pip --version && rm -v get-pip.pyUpon success if user is foo it'll print:
pip 21.3.1 from /home/foo/TensorFlow1.5/lib/python3.6/site-packages/pip (python 3.6) -
Ensure TensorFlow dependencies availability
pip install wheel==0.3.0 pip install absl-py==0.11.0 pip install six==1.10.0 pip install numpy==1.14.5 pip install protobuf==3.4.0 pip install keras==2.1.5 -
Get the TensorFlow itself and then verify
pip install tensorflow==1.5`
pip show tensorflow`
Satisfying every preceding requirement should succeed producing Python and TensorFlow running smoothly on a CPU void of AVX instruction
For example it will do
https://github.com/abdulbadii/chessboard-reader-by-old-TensorFlow-and-Python