facebookresearch / xformers

Hackable and optimized Transformers building blocks, supporting a composable construction.
https://facebookresearch.github.io/xformers/
Other
8.64k stars 613 forks source link

Whether windwos is supported? #501

Open Lufffya opened 2 years ago

Lufffya commented 2 years ago

❓ Questions and Help

danthe3rd commented 2 years ago

Hi, Windows is supported, but you will have to build xFormers yourself as we don't provide windows binaries at the moment

Lufffya commented 2 years ago

Hi, Windows is supported, but you will have to build xFormers yourself as we don't provide windows binaries at the moment

I see. But cuda can only be 11.3 and 11.6, which makes me confused, can other versions, such as 11.8?

danthe3rd commented 2 years ago

We provide binaries for cuda 11.3 and 11.6 (but only for linux and specific versions of pytorch). If you build from source, we support any version of cuda >= 11.3 (and maybe even earlier versions of CUDA, but not tested).

BlankFX1 commented 1 year ago

Windows is not really supported. The information you have to compile it yourself, is of no use, as Anaconda for Windows is not designed to be able to handle the long filenames this repo uses. It will always run into an error stating "Filename too long" in its default configuration.

And as Anaconda ignores the .condarc-File it generated itself, I also haven't found out a way to move it to another target folder.

danthe3rd commented 1 year ago

The "filename too long" is a limitation in Windows, that can be addressed.

You can also download windows builds from there (have to be installed manually): https://github.com/facebookresearch/xformers/actions/runs/3616539007

BlankFX1 commented 1 year ago

In addition to Windows' limitation also git has to be configured to use long filenames by using git config --system core.longpaths true

Sadly none of this will help, as ninja doesn't appear to be working with long filenames either. I'm aware of no fix.

ninja: error: Stat(C:/Users/[...]/xformers/components/attention/csrc/attention.obj): Filename longer than 260 characters.

Uninstalling ninja (and making sure it really is) irritatingly makes no difference, giving the exact same error.

Will try my luck with the windows builds you kindly mentioned.

bottler commented 1 year ago

@BlankFX1 I think another user had luck by moving the build to a directory with a short name. I'm not sure how long your ... is. Can you try working somewhere likec:\t?

BlankFX1 commented 1 year ago

As mentioned above I tried moving that folder yesterday by telling Anaconda to use a very short path. Sadly Anaconda keeps ignoring the .condarc-File it generated itself and I'm not familiar enough with it to know how I can tell it else what folder to use.

Working with the linked windows builds didn't work either as none of them appears to be compatible

WARNING: Could not find module 'B:\anaconda3\envs\db-diffusers\Lib\site-packages\xformers_C.pyd' (or one of its dependencies). Try using the full path with constructor syntax.

yocabon commented 1 year ago

Hi, Long paths can be enabled on Windows 10, version 1607, and later (not just with git), so it shouldn't be an issue (saw that in https://github.com/facebookresearch/xformers/issues/543 they get the same error).

Just run in an elevated powershell prompt (I'm not aware of any downside to enabling them, but there may be)

New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force

reference: https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=powershell

bangonkali commented 1 year ago

Hi guys, I ran the following:

pip install ninja
git config --system core.longpaths true
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force

Redacted logs are as follows:

(venv) PS C:\Users\Bangonkali\Desktop\Projects\stable-diffusion-webui> pip install ninja
Requirement already satisfied: ninja in c:\users\bangonkali\desktop\projects\stable-diffusion-webui\venv\lib\site-packages (1.11.1)
(venv) PS C:\Users\Bangonkali\Desktop\Projects\stable-diffusion-webui>
(venv) PS C:\Users\Bangonkali\Desktop\Projects\stable-diffusion-webui> git config --system core.longpaths true
(venv) PS C:\Users\Bangonkali\Desktop\Projects\stable-diffusion-webui> New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force

LongPathsEnabled : 1
PSPath           : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem
PSParentPath     : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control
PSChildName      : FileSystem
PSDrive          : HKLM
PSProvider       : Microsoft.PowerShell.Core\Registry

(venv) PS C:\Users\Bangonkali\Desktop\Projects\stable-diffusion-webui> pip install -v -U git+https://github.com/facebookresearch/xformers.g
it@main#egg=xformers
Using pip 22.3.1 from C:\Users\Bangonkali\Desktop\Projects\stable-diffusion-webui\venv\lib\site-packages\pip (python 3.10)
Collecting xformers
  Cloning https://github.com/facebookresearch/xformers.git (to revision main) to c:\users\bangonkali\appdata\local\temp\pip-install-83oykyll\xformers_b9a263a0d0cb4eb49808ee420fcb6556
  Running command git version
  git version 2.38.0.windows.1
  Running command git clone --filter=blob:none https://github.com/facebookresearch/xformers.git 'C:\Users\Bangonkali\AppData\Local\Temp\pip-install-83oykyll\xformers_b9a263a0d0cb4eb49808ee420fcb6556'
  Cloning into 'C:\Users\Bangonkali\AppData\Local\Temp\pip-install-83oykyll\xformers_b9a263a0d0cb4eb49808ee420fcb6556'...
  Updating files:   0% (2/632)
....
....
....
  Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N)
  ninja: error: Stat(C:/Users/Bangonkali/AppData/Local/Temp/pip-install-83oykyll/xformers_b9a263a0d0cb4eb49808ee420fcb6556/build/temp.win32-cpython-310/Release/Users/Bangonkali/AppData/Local/Temp/pip-install-83oykyll/xformers_b9a263a0d0cb4eb49808ee420fcb6556/xformers/components/attention/csrc/attention.obj): Filename longer than 260 characters
  Traceback (most recent call last):
    File "C:\Users\Bangonkali\Desktop\Projects\stable-diffusion-webui\venv\lib\site-packages\torch\utils\cpp_extension.py", line 1808, in _run_ninja_build
      subprocess.run(
    File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\subprocess.py", line 526, in run
      raise CalledProcessError(retcode, process.args,
  subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.

From within that, I got:

83oykyll/xformers_b9a263a0d0cb4eb49808ee420fcb6556/xformers/components/attention/csrc/attention.obj): Filename longer than 260 characters

I'm using elevated Windows PowerShell for VS 2022 with Microsoft Build Tools preinstalled.

image

It seems something else is still enforcing 260 character filename length limit.

Attached full log: ninja-windows-10-long-file-path.txt

bangonkali commented 1 year ago

It seems it could be related to this https://github.com/ninja-build/ninja/issues/1900