SYSTEM NOTICE

Auto translation by AI. Be sure, accuracy, nuances and authorial intent may not be fully reflected.
見出し画像

How to update Python from Tar&Flash-Attention2 for Pytorch 2.7.1+cu128


As of August 10, 2025, the old methods no longer work at all, so I have completely revised the procedure.

Currently, my Python environment consists of version 3.11.9 installed globally, which I use primarily for A1111, Forge, reForge, etc., while ComfyUI uses a separate 3.12.x embedded environment completely isolated from the 3.11.9 environment.

Now, getting to the main point: whether it is 3.11.x or 3.12.x, the latest versions are not always distributed in installer format; once they reach a certain point, they are only distributed in Tar format.

These updates are often primarily for security, and even though they don't come with an installer, the updates themselves are often recommended.

The latest 3.11 version, 3.11.13, is as follows. Development is already complete, and 3.14.x is currently being introduced.

This time, I performed a build from this tar-format source code and overwrote the existing 3.11.9 installation. The following is an explanation regarding the update to 3.11.13, but the method remains the same even when newer versions are released.

Python 3.11.9 → 3.11.13 Source Build Update Procedure

The following is executed using the paths from my PC environment, so please change the paths as necessary.

Prerequisites

  • Visual Studio Build Tools 2019 or later installed

  • Git installed

  • Existing Python 3.11.9 installed

Procedure

1. Preparing the working directory

mkdir C:\python-build
cd C:\python-build

2. Obtaining the CPython source code

git clone https://github.com/python/cpython.git
cd cpython
git checkout v3.11.13

3. Preparing the build environment

python -m pip install --upgrade pip setuptools wheel

4. Building Python

cd PCBuild
.\build.bat -p x64 -c Release

5. Verifying the build results

.\amd64\python.exe --version

Expected output: `Python 3.11.13`

6. Copying to the existing Python installation

copy "amd64\python.exe" "C:\Users\ussoe\AppData\Local\Programs\Python\Python311\"
copy "amd64\pythonw.exe" "C:\Users\ussoe\AppData\Local\Programs\Python\Python311\"
copy "amd64\python311.dll" "C:\Users\ussoe\AppData\Local\Programs\Python\Python311\"
copy "amd64\python3.dll" "C:\Users\ussoe\AppData\Local\Programs\Python\Python311\"
copy "amd64\*.dll" "C:\Users\ussoe\AppData\Local\Programs\Python\Python311\"
cd ..
xcopy /E /I "Lib" "C:\Users\ussoe\AppData\Local\Programs\Python\Python311\Lib\"
xcopy /E /I "Include" "C:\Users\ussoe\AppData\Local\Programs\Python\Python311\Include\"
copy "LICENSE" "C:\Users\ussoe\AppData\Local\Programs\Python\Python311\" -ErrorAction SilentlyContinue
copy "README.rst" "C:\Users\ussoe\AppData\Local\Programs\Python\Python311\" -ErrorAction SilentlyContinue

7. Verification of update

python --version
python -c "import sys; print(f'Python {sys.version}')"
python -c "print('Hello, Python 3.11.13!')"

8. Post-processing and confirmation

pip --version
pip list
python -m ensurepip --upgrade
python -c "import pip; print('pip is working')"
python -c "import setuptools; print('setuptools is working')"

Notes

  • The build process takes time (approximately 30 minutes to 1 hour)

  • Sufficient disk space is required (several GB)

  • Existing Python packages will be retained, but verification is recommended

  • If problems occur, it is recommended to have a backup of the original Python installation

Troubleshooting

  • Do not use `setup.py build` (use `PCBuild\build.bat` on Windows)

  • Build output is placed in the `PCBuild\amd64` directory

  • Use a Release build instead of a Debug build (use the `-c Release` option)

...

Now, with the release of Pytorch 2.7.1+cu128, I have also built Flash-Attention2 for Windows. As with last time, it is 2.7.4 post1. I have released versions for Python 3.11 and 3.12.

Note that while the latest FA2 is 2.8.0 post2, it cannot be built with the batch file introduced in the article above. I spent a considerable amount of time investigating this with Mr. Manus, but it was not possible.

I assume the author is aware of the issues, but we have no choice but to rely on the author's expertise. For now, it was beyond my capabilities at this time.

いいなと思ったら応援しよう!