stablediffusion
stablediffusion copied to clipboard
xformers installation instructions not working
On Ubuntu 22.04 (with a 2080 TI, intel CPU), I am following the installation instructions to the letter. I'm in the ldm conda environment. I enter the following as per README.md:
(ldm) sam@sam-desktop:~/workspace$ export CUDA_HOME=/usr/local/cuda-11.4
(ldm) sam@sam-desktop:~/workspace$ conda install -c nvidia/label/cuda-11.4.0 cuda-nvcc
Collecting package metadata (current_repodata.json): done
Solving environment: done
# All requested packages already installed.
(ldm) sam@sam-desktop:~/workspace$ conda install -c conda-forge gcc
Collecting package metadata (current_repodata.json): done
Solving environment: done
## Package Plan ##
environment location: /home/sam/miniconda3/envs/ldm
added / updated specs:
- gcc
The following packages will be SUPERSEDED by a higher-priority channel:
ca-certificates pkgs/main::ca-certificates-2023.01.10~ --> conda-forge::ca-certificates-2022.12.7-ha878542_0
certifi pkgs/main/linux-64::certifi-2022.12.7~ --> conda-forge/noarch::certifi-2022.12.7-pyhd8ed1ab_0
openssl pkgs/main::openssl-1.1.1t-h7f8727e_0 --> conda-forge::openssl-1.1.1t-h0b41bf4_0
Proceed ([y]/n)? y
Downloading and Extracting Packages
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
(ldm) sam@sam-desktop:~/workspace$ conda install -c conda-forge gxx_linux-64==9.5.0
Collecting package metadata (current_repodata.json): done
Solving environment: done
# All requested packages already installed.
(ldm) sam@sam-desktop:~/workspace$ git clone https://github.com/facebookresearch/xformers.git
Cloning into 'xformers'...
remote: Enumerating objects: 9944, done.
remote: Counting objects: 100% (295/295), done.
remote: Compressing objects: 100% (123/123), done.
remote: Total 9944 (delta 170), reused 281 (delta 170), pack-reused 9649
Receiving objects: 100% (9944/9944), 36.68 MiB | 33.93 MiB/s, done.
Resolving deltas: 100% (6709/6709), done.
(ldm) sam@sam-desktop:~/workspace$ cd xformers
(ldm) sam@sam-desktop:~/workspace/xformers$ git submodule update --init --recursive
Submodule 'third_party/cutlass' (https://github.com/NVIDIA/cutlass.git) registered for path 'third_party/cutlass'
Submodule 'third_party/flash-attention' (https://github.com/HazyResearch/flash-attention.git) registered for path 'third_party/flash-attention'
Cloning into '/home/sam/workspace/xformers/third_party/cutlass'...
Cloning into '/home/sam/workspace/xformers/third_party/flash-attention'...
Submodule path 'third_party/cutlass': checked out '06eb90cc0daae633b1e25e80ace1ef81ac158baa'
Submodule path 'third_party/flash-attention': checked out 'a1f49a2b92b6fa022379bbebafed9d7f5e96a675'
Submodule 'csrc/flash_attn/cutlass' (https://github.com/NVIDIA/cutlass.git) registered for path 'third_party/flash-attention/csrc/flash_attn/cutlass'
Cloning into '/home/sam/workspace/xformers/third_party/flash-attention/csrc/flash_attn/cutlass'...
Submodule path 'third_party/flash-attention/csrc/flash_attn/cutlass': checked out '319a389f42b776fae5701afcb943fc03be5b5c25'
(ldm) sam@sam-desktop:~/workspace/xformers$ pip install -r requirements.txt
Requirement already satisfied: torch>=1.12 in /home/sam/miniconda3/envs/ldm/lib/python3.8/site-packages (from -r requirements.txt (line 3)) (1.12.1)
Requirement already satisfied: numpy in /home/sam/miniconda3/envs/ldm/lib/python3.8/site-packages (from -r requirements.txt (line 4)) (1.23.1)
Requirement already satisfied: pyre-extensions==0.0.23 in /home/sam/miniconda3/envs/ldm/lib/python3.8/site-packages (from -r requirements.txt (line 5)) (0.0.23)
Requirement already satisfied: typing-extensions in /home/sam/miniconda3/envs/ldm/lib/python3.8/site-packages (from pyre-extensions==0.0.23->-r requirements.txt (line 5)) (4.4.0)
Requirement already satisfied: typing-inspect in /home/sam/miniconda3/envs/ldm/lib/python3.8/site-packages (from pyre-extensions==0.0.23->-r requirements.txt (line 5)) (0.8.0)
Requirement already satisfied: mypy-extensions>=0.3.0 in /home/sam/miniconda3/envs/ldm/lib/python3.8/site-packages (from typing-inspect->pyre-extensions==0.0.23->-r requirements.txt (line 5)) (1.0.0)
(ldm) sam@sam-desktop:~/workspace/xformers$ pip install -e .
Obtaining file:///home/sam/workspace/xformers
ERROR: Command errored out with exit status 1:
command: /home/sam/miniconda3/envs/ldm/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/sam/workspace/xformers/setup.py'"'"'; __file__='"'"'/home/sam/workspace/xformers/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-opgi85ik
cwd: /home/sam/workspace/xformers/
Complete output (17 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/sam/workspace/xformers/setup.py", line 362, in <module>
extensions, extensions_metadata = get_extensions()
File "/home/sam/workspace/xformers/setup.py", line 234, in get_extensions
cuda_version = get_cuda_version(CUDA_HOME)
File "/home/sam/workspace/xformers/setup.py", line 95, in get_cuda_version
raw_output = subprocess.check_output([nvcc_bin, "-V"], universal_newlines=True)
File "/home/sam/miniconda3/envs/ldm/lib/python3.8/subprocess.py", line 411, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "/home/sam/miniconda3/envs/ldm/lib/python3.8/subprocess.py", line 489, in run
with Popen(*popenargs, **kwargs) as process:
File "/home/sam/miniconda3/envs/ldm/lib/python3.8/subprocess.py", line 854, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/home/sam/miniconda3/envs/ldm/lib/python3.8/subprocess.py", line 1702, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/cuda-11.4/bin/nvcc'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
The directory being referenced by the CUDA_HOME
environment variable does not exist:
(ldm) sam@sam-desktop:~/workspace/xformers$ ls /usr/local/cuda-11.4
ls: cannot access '/usr/local/cuda-11.4': No such file or directory
Nor does such a directory exist anywhere on my machine:
(ldm) sam@sam-desktop:~/workspace/xformers$ sudo find / -name cuda-11.4
[sudo] password for sam:
find: ‘/run/user/1000/doc’: Permission denied
find: ‘/run/user/1000/gvfs’: Permission denied
(ldm) sam@sam-desktop:~/workspace/xformers$
If I try building xformers without this environment variable I get:
(ldm) sam@sam-desktop:~/workspace/xformers$ unset CUDA_HOME
(ldm) sam@sam-desktop:~/workspace/xformers$ pip install -e .
Obtaining file:///home/sam/workspace/xformers
Requirement already satisfied: torch>=1.12 in /home/sam/miniconda3/envs/ldm/lib/python3.8/site-packages (from xformers==0.0.17+cc36858.d20230218) (1.12.1)
Requirement already satisfied: numpy in /home/sam/miniconda3/envs/ldm/lib/python3.8/site-packages (from xformers==0.0.17+cc36858.d20230218) (1.23.1)
Requirement already satisfied: pyre-extensions==0.0.23 in /home/sam/miniconda3/envs/ldm/lib/python3.8/site-packages (from xformers==0.0.17+cc36858.d20230218) (0.0.23)
Requirement already satisfied: typing-inspect in /home/sam/miniconda3/envs/ldm/lib/python3.8/site-packages (from pyre-extensions==0.0.23->xformers==0.0.17+cc36858.d20230218) (0.8.0)
Requirement already satisfied: typing-extensions in /home/sam/miniconda3/envs/ldm/lib/python3.8/site-packages (from pyre-extensions==0.0.23->xformers==0.0.17+cc36858.d20230218) (4.4.0)
Requirement already satisfied: mypy-extensions>=0.3.0 in /home/sam/miniconda3/envs/ldm/lib/python3.8/site-packages (from typing-inspect->pyre-extensions==0.0.23->xformers==0.0.17+cc36858.d20230218) (1.0.0)
Installing collected packages: xformers
Running setup.py develop for xformers
ERROR: Command errored out with exit status 1:
command: /home/sam/miniconda3/envs/ldm/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/sam/workspace/xformers/setup.py'"'"'; __file__='"'"'/home/sam/workspace/xformers/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps
cwd: /home/sam/workspace/xformers/
Complete output (37 lines):
running develop
running egg_info
creating xformers.egg-info
writing xformers.egg-info/PKG-INFO
writing dependency_links to xformers.egg-info/dependency_links.txt
writing requirements to xformers.egg-info/requires.txt
writing top-level names to xformers.egg-info/top_level.txt
writing manifest file 'xformers.egg-info/SOURCES.txt'
reading manifest file 'xformers.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
adding license file 'LICENSE'
writing manifest file 'xformers.egg-info/SOURCES.txt'
running build_ext
building 'xformers._C_flashattention' extension
creating build
creating build/temp.linux-x86_64-cpython-38
creating build/temp.linux-x86_64-cpython-38/third_party
creating build/temp.linux-x86_64-cpython-38/third_party/flash-attention
creating build/temp.linux-x86_64-cpython-38/third_party/flash-attention/csrc
creating build/temp.linux-x86_64-cpython-38/third_party/flash-attention/csrc/flash_attn
creating build/temp.linux-x86_64-cpython-38/third_party/flash-attention/csrc/flash_attn/src
/home/sam/miniconda3/envs/ldm/bin/x86_64-conda-linux-gnu-cc -Wno-unused-result -Wsign-compare -DNDEBUG -fwrapv -O2 -Wall -Wstrict-prototypes -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -pipe -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -pipe -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/sam/miniconda3/envs/ldm/include -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /home/sam/miniconda3/envs/ldm/include -fPIC -I/home/sam/workspace/xformers/third_party/flash-attention/csrc/flash_attn -I/home/sam/workspace/xformers/third_party/flash-attention/csrc/flash_attn/src -I/home/sam/workspace/xformers/third_party/cutlass/include -I/home/sam/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/include -I/home/sam/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/include/torch/csrc/api/include -I/home/sam/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/include/TH -I/home/sam/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/include/THC -I/home/sam/miniconda3/envs/ldm/include -I/home/sam/miniconda3/envs/ldm/include/python3.8 -c third_party/flash-attention/csrc/flash_attn/fmha_api.cpp -o build/temp.linux-x86_64-cpython-38/third_party/flash-attention/csrc/flash_attn/fmha_api.o -O3 -fopenmp -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE=\"_gcc\" -DPYBIND11_STDLIB=\"_libstdcpp\" -DPYBIND11_BUILD_ABI=\"_cxxabi1011\" -DTORCH_EXTENSION_NAME=_C_flashattention -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++14
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
In file included from third_party/flash-attention/csrc/flash_attn/fmha_api.cpp:30:
/home/sam/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/include/ATen/cuda/CUDAContext.h:5:10: fatal error: cuda_runtime_api.h: No such file or directory
5 | #include <cuda_runtime_api.h>
| ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
/home/sam/miniconda3/envs/ldm/lib/python3.8/site-packages/setuptools/command/easy_install.py:144: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
/home/sam/miniconda3/envs/ldm/lib/python3.8/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
/home/sam/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/utils/cpp_extension.py:411: UserWarning: Attempted to use ninja as the BuildExtension backend but we could not find ninja.. Falling back to using the slow distutils backend.
warnings.warn(msg.format('we could not find ninja.'))
/home/sam/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/utils/cpp_extension.py:813: UserWarning: The detected CUDA version (11.4) has a minor version mismatch with the version that was used to compile PyTorch (11.3). Most likely this shouldn't be a problem.
warnings.warn(CUDA_MISMATCH_WARN.format(cuda_str_version, torch.version.cuda))
error: command '/home/sam/miniconda3/envs/ldm/bin/x86_64-conda-linux-gnu-cc' failed with exit code 1
----------------------------------------
ERROR: Command errored out with exit status 1: /home/sam/miniconda3/envs/ldm/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/sam/workspace/xformers/setup.py'"'"'; __file__='"'"'/home/sam/workspace/xformers/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps Check the logs for full command output.
I'd be happy to submit a pull request updating the instructions to correct this issue, but I'm not sure what I'm doing wrong. Is there some implied step where I'm supposed to install some additional CUDA thing?
For me when I execute the command conda install -c conda-forge gcc
I get an infinite loop:
(base) xxx@xxx:~$ conda install -c conda-forge gcc
Collecting package metadata (current_repodata.json): done
Solving environment: /
I encountered the same problem
(ldm) root@barista-cf4e41e7:/local/guoling/Diffusion_model/xformers# pip install -e .
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Obtaining file:///local/guoling/Diffusion_model/xformers
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [8 lines of output]
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "/local/guoling/Diffusion_model/xformers/setup.py", line 23, in <module>
import torch
File "/opt/conda/envs/ldm/lib/python3.8/site-packages/torch/__init__.py", line 202, in <module>
from torch._C import * # noqa: F403
ImportError: /opt/conda/envs/ldm/lib/python3.8/site-packages/torch/lib/../../../../libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by /opt/conda/envs/ldm/lib/python3.8/site-packages/torch/lib/libtorch_python.so)
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
I have tried many methods like updating pip and setup tools, but the issue keeps existing. Anybody know how to solve this?
same problem
On Ubuntu 22.04 (with a 2080 TI, intel CPU), I am following the installation instructions to the letter. I'm in the ldm conda environment. I enter the following as per README.md:
(ldm) sam@sam-desktop:~/workspace$ export CUDA_HOME=/usr/local/cuda-11.4 (ldm) sam@sam-desktop:~/workspace$ conda install -c nvidia/label/cuda-11.4.0 cuda-nvcc Collecting package metadata (current_repodata.json): done Solving environment: done # All requested packages already installed. (ldm) sam@sam-desktop:~/workspace$ conda install -c conda-forge gcc Collecting package metadata (current_repodata.json): done Solving environment: done ## Package Plan ## environment location: /home/sam/miniconda3/envs/ldm added / updated specs: - gcc The following packages will be SUPERSEDED by a higher-priority channel: ca-certificates pkgs/main::ca-certificates-2023.01.10~ --> conda-forge::ca-certificates-2022.12.7-ha878542_0 certifi pkgs/main/linux-64::certifi-2022.12.7~ --> conda-forge/noarch::certifi-2022.12.7-pyhd8ed1ab_0 openssl pkgs/main::openssl-1.1.1t-h7f8727e_0 --> conda-forge::openssl-1.1.1t-h0b41bf4_0 Proceed ([y]/n)? y Downloading and Extracting Packages Preparing transaction: done Verifying transaction: done Executing transaction: done (ldm) sam@sam-desktop:~/workspace$ conda install -c conda-forge gxx_linux-64==9.5.0 Collecting package metadata (current_repodata.json): done Solving environment: done # All requested packages already installed. (ldm) sam@sam-desktop:~/workspace$ git clone https://github.com/facebookresearch/xformers.git Cloning into 'xformers'... remote: Enumerating objects: 9944, done. remote: Counting objects: 100% (295/295), done. remote: Compressing objects: 100% (123/123), done. remote: Total 9944 (delta 170), reused 281 (delta 170), pack-reused 9649 Receiving objects: 100% (9944/9944), 36.68 MiB | 33.93 MiB/s, done. Resolving deltas: 100% (6709/6709), done. (ldm) sam@sam-desktop:~/workspace$ cd xformers (ldm) sam@sam-desktop:~/workspace/xformers$ git submodule update --init --recursive Submodule 'third_party/cutlass' (https://github.com/NVIDIA/cutlass.git) registered for path 'third_party/cutlass' Submodule 'third_party/flash-attention' (https://github.com/HazyResearch/flash-attention.git) registered for path 'third_party/flash-attention' Cloning into '/home/sam/workspace/xformers/third_party/cutlass'... Cloning into '/home/sam/workspace/xformers/third_party/flash-attention'... Submodule path 'third_party/cutlass': checked out '06eb90cc0daae633b1e25e80ace1ef81ac158baa' Submodule path 'third_party/flash-attention': checked out 'a1f49a2b92b6fa022379bbebafed9d7f5e96a675' Submodule 'csrc/flash_attn/cutlass' (https://github.com/NVIDIA/cutlass.git) registered for path 'third_party/flash-attention/csrc/flash_attn/cutlass' Cloning into '/home/sam/workspace/xformers/third_party/flash-attention/csrc/flash_attn/cutlass'... Submodule path 'third_party/flash-attention/csrc/flash_attn/cutlass': checked out '319a389f42b776fae5701afcb943fc03be5b5c25' (ldm) sam@sam-desktop:~/workspace/xformers$ pip install -r requirements.txt Requirement already satisfied: torch>=1.12 in /home/sam/miniconda3/envs/ldm/lib/python3.8/site-packages (from -r requirements.txt (line 3)) (1.12.1) Requirement already satisfied: numpy in /home/sam/miniconda3/envs/ldm/lib/python3.8/site-packages (from -r requirements.txt (line 4)) (1.23.1) Requirement already satisfied: pyre-extensions==0.0.23 in /home/sam/miniconda3/envs/ldm/lib/python3.8/site-packages (from -r requirements.txt (line 5)) (0.0.23) Requirement already satisfied: typing-extensions in /home/sam/miniconda3/envs/ldm/lib/python3.8/site-packages (from pyre-extensions==0.0.23->-r requirements.txt (line 5)) (4.4.0) Requirement already satisfied: typing-inspect in /home/sam/miniconda3/envs/ldm/lib/python3.8/site-packages (from pyre-extensions==0.0.23->-r requirements.txt (line 5)) (0.8.0) Requirement already satisfied: mypy-extensions>=0.3.0 in /home/sam/miniconda3/envs/ldm/lib/python3.8/site-packages (from typing-inspect->pyre-extensions==0.0.23->-r requirements.txt (line 5)) (1.0.0) (ldm) sam@sam-desktop:~/workspace/xformers$ pip install -e . Obtaining file:///home/sam/workspace/xformers ERROR: Command errored out with exit status 1: command: /home/sam/miniconda3/envs/ldm/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/sam/workspace/xformers/setup.py'"'"'; __file__='"'"'/home/sam/workspace/xformers/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-opgi85ik cwd: /home/sam/workspace/xformers/ Complete output (17 lines): Traceback (most recent call last): File "<string>", line 1, in <module> File "/home/sam/workspace/xformers/setup.py", line 362, in <module> extensions, extensions_metadata = get_extensions() File "/home/sam/workspace/xformers/setup.py", line 234, in get_extensions cuda_version = get_cuda_version(CUDA_HOME) File "/home/sam/workspace/xformers/setup.py", line 95, in get_cuda_version raw_output = subprocess.check_output([nvcc_bin, "-V"], universal_newlines=True) File "/home/sam/miniconda3/envs/ldm/lib/python3.8/subprocess.py", line 411, in check_output return run(*popenargs, stdout=PIPE, timeout=timeout, check=True, File "/home/sam/miniconda3/envs/ldm/lib/python3.8/subprocess.py", line 489, in run with Popen(*popenargs, **kwargs) as process: File "/home/sam/miniconda3/envs/ldm/lib/python3.8/subprocess.py", line 854, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "/home/sam/miniconda3/envs/ldm/lib/python3.8/subprocess.py", line 1702, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/cuda-11.4/bin/nvcc' ---------------------------------------- ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
The directory being referenced by the
CUDA_HOME
environment variable does not exist:(ldm) sam@sam-desktop:~/workspace/xformers$ ls /usr/local/cuda-11.4 ls: cannot access '/usr/local/cuda-11.4': No such file or directory
Nor does such a directory exist anywhere on my machine:
(ldm) sam@sam-desktop:~/workspace/xformers$ sudo find / -name cuda-11.4 [sudo] password for sam: find: ‘/run/user/1000/doc’: Permission denied find: ‘/run/user/1000/gvfs’: Permission denied (ldm) sam@sam-desktop:~/workspace/xformers$
If I try building xformers without this environment variable I get:
(ldm) sam@sam-desktop:~/workspace/xformers$ unset CUDA_HOME (ldm) sam@sam-desktop:~/workspace/xformers$ pip install -e . Obtaining file:///home/sam/workspace/xformers Requirement already satisfied: torch>=1.12 in /home/sam/miniconda3/envs/ldm/lib/python3.8/site-packages (from xformers==0.0.17+cc36858.d20230218) (1.12.1) Requirement already satisfied: numpy in /home/sam/miniconda3/envs/ldm/lib/python3.8/site-packages (from xformers==0.0.17+cc36858.d20230218) (1.23.1) Requirement already satisfied: pyre-extensions==0.0.23 in /home/sam/miniconda3/envs/ldm/lib/python3.8/site-packages (from xformers==0.0.17+cc36858.d20230218) (0.0.23) Requirement already satisfied: typing-inspect in /home/sam/miniconda3/envs/ldm/lib/python3.8/site-packages (from pyre-extensions==0.0.23->xformers==0.0.17+cc36858.d20230218) (0.8.0) Requirement already satisfied: typing-extensions in /home/sam/miniconda3/envs/ldm/lib/python3.8/site-packages (from pyre-extensions==0.0.23->xformers==0.0.17+cc36858.d20230218) (4.4.0) Requirement already satisfied: mypy-extensions>=0.3.0 in /home/sam/miniconda3/envs/ldm/lib/python3.8/site-packages (from typing-inspect->pyre-extensions==0.0.23->xformers==0.0.17+cc36858.d20230218) (1.0.0) Installing collected packages: xformers Running setup.py develop for xformers ERROR: Command errored out with exit status 1: command: /home/sam/miniconda3/envs/ldm/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/sam/workspace/xformers/setup.py'"'"'; __file__='"'"'/home/sam/workspace/xformers/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps cwd: /home/sam/workspace/xformers/ Complete output (37 lines): running develop running egg_info creating xformers.egg-info writing xformers.egg-info/PKG-INFO writing dependency_links to xformers.egg-info/dependency_links.txt writing requirements to xformers.egg-info/requires.txt writing top-level names to xformers.egg-info/top_level.txt writing manifest file 'xformers.egg-info/SOURCES.txt' reading manifest file 'xformers.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' adding license file 'LICENSE' writing manifest file 'xformers.egg-info/SOURCES.txt' running build_ext building 'xformers._C_flashattention' extension creating build creating build/temp.linux-x86_64-cpython-38 creating build/temp.linux-x86_64-cpython-38/third_party creating build/temp.linux-x86_64-cpython-38/third_party/flash-attention creating build/temp.linux-x86_64-cpython-38/third_party/flash-attention/csrc creating build/temp.linux-x86_64-cpython-38/third_party/flash-attention/csrc/flash_attn creating build/temp.linux-x86_64-cpython-38/third_party/flash-attention/csrc/flash_attn/src /home/sam/miniconda3/envs/ldm/bin/x86_64-conda-linux-gnu-cc -Wno-unused-result -Wsign-compare -DNDEBUG -fwrapv -O2 -Wall -Wstrict-prototypes -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -pipe -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -pipe -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/sam/miniconda3/envs/ldm/include -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /home/sam/miniconda3/envs/ldm/include -fPIC -I/home/sam/workspace/xformers/third_party/flash-attention/csrc/flash_attn -I/home/sam/workspace/xformers/third_party/flash-attention/csrc/flash_attn/src -I/home/sam/workspace/xformers/third_party/cutlass/include -I/home/sam/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/include -I/home/sam/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/include/torch/csrc/api/include -I/home/sam/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/include/TH -I/home/sam/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/include/THC -I/home/sam/miniconda3/envs/ldm/include -I/home/sam/miniconda3/envs/ldm/include/python3.8 -c third_party/flash-attention/csrc/flash_attn/fmha_api.cpp -o build/temp.linux-x86_64-cpython-38/third_party/flash-attention/csrc/flash_attn/fmha_api.o -O3 -fopenmp -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE=\"_gcc\" -DPYBIND11_STDLIB=\"_libstdcpp\" -DPYBIND11_BUILD_ABI=\"_cxxabi1011\" -DTORCH_EXTENSION_NAME=_C_flashattention -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++14 cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++ In file included from third_party/flash-attention/csrc/flash_attn/fmha_api.cpp:30: /home/sam/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/include/ATen/cuda/CUDAContext.h:5:10: fatal error: cuda_runtime_api.h: No such file or directory 5 | #include <cuda_runtime_api.h> | ^~~~~~~~~~~~~~~~~~~~ compilation terminated. /home/sam/miniconda3/envs/ldm/lib/python3.8/site-packages/setuptools/command/easy_install.py:144: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools. warnings.warn( /home/sam/miniconda3/envs/ldm/lib/python3.8/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools. warnings.warn( /home/sam/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/utils/cpp_extension.py:411: UserWarning: Attempted to use ninja as the BuildExtension backend but we could not find ninja.. Falling back to using the slow distutils backend. warnings.warn(msg.format('we could not find ninja.')) /home/sam/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/utils/cpp_extension.py:813: UserWarning: The detected CUDA version (11.4) has a minor version mismatch with the version that was used to compile PyTorch (11.3). Most likely this shouldn't be a problem. warnings.warn(CUDA_MISMATCH_WARN.format(cuda_str_version, torch.version.cuda)) error: command '/home/sam/miniconda3/envs/ldm/bin/x86_64-conda-linux-gnu-cc' failed with exit code 1 ---------------------------------------- ERROR: Command errored out with exit status 1: /home/sam/miniconda3/envs/ldm/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/sam/workspace/xformers/setup.py'"'"'; __file__='"'"'/home/sam/workspace/xformers/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps Check the logs for full command output.
I'd be happy to submit a pull request updating the instructions to correct this issue, but I'm not sure what I'm doing wrong. Is there some implied step where I'm supposed to install some additional CUDA thing?
When I download the xformers repository directly, I get the same error as you. But clone will solve this problem.
export CUDA_HOME=/usr/local/cuda-11.3
conda install -c nvidia/label/cuda-11.3.0 cuda-nvcc
conda install -c conda-forge gcc
conda install -c conda-forge gxx_linux-64==9.5.0
cd ..
git clone https://github.com/facebookresearch/xformers.git
cd xformers
git submodule update --init --recursive
pip install -r requirements.txt
pip install -e .
cd ../stablediffusion
I was able to resolve the missing #include <cuda_runtime_api.h>
issue by installing full cuda through conda:
conda install cuda -c nvidia/label/cuda-11.4.0
Instead of compiling xformers, I followed the recommended from their repo and just installed the prebuilt binaries (you may need reacreate ldm using python version 3.9):
conda install xformers
https://github.com/Stability-AI/stablediffusion/issues/38#issuecomment-1327522703
I managed to fix the issue since I was installing in a conda environment by replacing
export CUDA_HOME=/usr/local/cuda-11.4
with
export CUDA_HOME=~/miniconda3/envs/<name-of-conda-env>
Assuming installation using miniconda3 and running in an existing environment. It looks like when you install cuda through conda it doesn't create a folder named cuda-11.4 or whatever version was installed, but it does create the nvcc binary in the conda environment
try https://github.com/facebookresearch/xformers/issues/960 , you can build with cuda12 latest version or any version you have.