Since TensorFlow 1.15 has conflicting definitions, we must patch the CUDA headers.
cd /usr/local/cuda-12.9/ sudo patch -p1 < cuda-12.9.patch
Bazel 0.26.1 is required. Modern versions will not work.
wget https://releases.bazel.build/0.26.1/release/bazel-0.26.1-installer-linux-x86_64.sh bash bazel-0.26.1-installer-linux-x86_64.sh
If you use virtualenv, install the dependencies in the virtual environment. keras-preprocessing causes errors with python3.12, so we install it directly from the master branch.
sudo apt install python3-dev python3-pip git unzip (cd /usr/bin && sudo ln -s python3 python) pip3 install 'numpy<2' pip3 install git+https://github.com/keras-team/keras-preprocessing.git
Apply a patch to the Tensorflow1.15 source code to make it build with cuda12.9. In the case of python3.12, various issues may arise, so we modify the modules accordingly.
cd tensorflow patch -p1 < ../tensorflow-1.15.5-cuda12.9-ubuntu24.04.patch
cd tensorflow ./configure
The default settings are fine. When asked about CUDA, answer Yes, and specify the Compute Capability as 7.5, 8.0, 8.6, 8.9, 9.0, 10.0, 10.3, 12.0. Removing unused GPU capabilities will speed up compilation.
CUDA12.9 is automatically recognized as being located at /usr/local/cuda, but for some reason, the include paths are messed up, causing the build to fail. Edit the .tf_configure.bazelrc file, find /usr/local/cuda, and change the path to /usr/local/cuda-12.9.
build --action_env CUDA_TOOLKIT_PATH="/usr/local/cuda-12.9"
bazel build --config=opt --verbose_failures //tensorflow/tools/pip_package:build_pip_package
Building may take several hours, so be patient.
./bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
A file named tensorflow-1.15.5-cp312-cp312-linux_x86_64.whl will be created in /tmp/tensorflow_pkg. Install this file to use TensorFlow. The cp312 part may vary depending on your Python version.
If you have any issues or feedback regarding the content, please contact us at contact@lithium03.info.
Back to Index