Install git for windows.
Install MSYS2.
After installing MSYS2, launch the MSYS2 MinGW 64-bit terminal and run the following commands to install the required packages:
pacman -Syu pacman -S diffutils patch unzip sed
Install Visual Studio 2026. https://visualstudio.microsoft.com/ja/downloads/ When installing, make sure to select "Desktop development with C++".
Next, to trick Bazel, we will fake the path. Open a command prompt and run the following command:
mklink /J C:\MSVC_2019 "C:\Program Files\Microsoft Visual Studio\18\Community"
The version of Bazel we are using only supports up to 2019, but as long as there is a number in the path, it will work. We will use the latest version of Visual Studio because the compilation related to CUDA fails with older versions.
Install CUDA Toolkit 12.9. https://developer.nvidia.com/compute/cuda/12.9.1/network_installers/cuda_12.9.1_windows_network.exe
Download from the following link: https://developer.nvidia.com/downloads/compute/cudnn/secure/8.9.7/local_installers/12.x/cudnn-windows-x86_64-8.9.7.29_cuda12-archive.zip/
Copy the extracted contents to the bin, include, and lib directories of the CUDA Toolkit installation directory c:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.9: Administrator privileges are required for this step.
Since TensorFlow 1.15 has conflicting definitions, we will trick the headers during compilation. After compilation, make sure to restore the original headers by writing back from the folder you used for orignal downloading.
If MSYS2 is installed, you can run the following command in the command prompt. Open a command prompt with administrator privileges and run the following command:
cd c:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.9 patch -p1 < cuda-12.9.patch
This time, we will use uv to install the Python environment. Open a command prompt and run the following command to install it.
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
We will use uv to install Python. Open a command prompt in any directory you wish to use for your work and run the following command.
uv init tensorflow1 --bare -p 3.12 cd tensorflow1 uv python pin 3.12
Next, we will install the required Python packages.
uv add 'numpy<2' uv add git+https://github.com/keras-team/keras-preprocessing.git uv add setuptools
bazel0.26.1 is required, so we will download it from the old location. The latest version of Bazel won't work. https://releases.bazel.build/0.26.1/release/bazel-0.26.1-windows-x86_64.exe
Download the file and place it in a directory that is in your PATH, renaming the file as needed. It would be good to place it in the execution directory of the virtual environment you just created.
copy bazel-0.26.1-windows-x86_64.exe tensorflow1\.venv\Scripts\bazel.exe
Open a command prompt and activate the virtual environment.
tensorflow1\.venv\Scripts\activate
The following work will be done with the virtual environment activated.
git clone -b r1.15 https://github.com/tensorflow/tensorflow.git
Apply a patch to the Tensorflow1.15 source code to make it build with cuda12.9. In the case of python3.12, various things will not work, so we are modifying the modules and such.
cd tensorflow patch -p1 < ../tensorflow-1.15.5-cuda12.9-python3.12.patch
Set the environment variables so that bazel can find the compiler. Run the following command in the command prompt.
set BAZEL_VC=C:\MSVC_2019\VC set BAZEL_VS=C:\MSVC_2019
cd tensorflow configure
The default settings are fine. For the CUDA question, answer Yes, and for Compute Capability, specify 7.5, 8.0, 8.6, 8.9, 9.0, 10.0, 10.3, 12.0. Removing unnecessary GPU ones will speed up the compilation.
bazel build --define=no_tensorflow_py_deps=true --config=opt --verbose_failures //tensorflow/tools/pip_package:build_pip_package
It will take several hours, so please have a cup of tea and wait.
bazel-bin\tensorflow\tools\pip_package\build_pip_package tensorflow_pkg
A file named tensorflow-1.15.5-cp312-cp312-win_amd64.whl will be created in tensorflow_pkg, which you can install and use. The cp312 part will vary depending on the Python version.
If you have any issues or feedback regarding the content, please contact us at contact@lithium03.info.
Back to Index