xformers icon indicating copy to clipboard operation
xformers copied to clipboard

FileNotFoundError while trying to build xformers from source

Open T0biasCZe opened this issue 6 months ago • 3 comments

❓ Questions and Help

I am trying to build and install xformers from source, since i have Cuda 12.3 and pytorch 2.2.0 nightly, I ran the command mentioned in the readme, and after while it throws this error I have both Cuda, NVCC and Visual C++ compiler installed

Collecting xformers
  Cloning https://github.com/facebookresearch/xformers.git (to revision main) to c:\users\tobik\appdata\local\temp\pip-install-gax_br8z\xformers_5eb9f324d43041db94297bbeec3c496d
  Running command git version
  git version 2.42.0.windows.2
  Running command git clone --filter=blob:none https://github.com/facebookresearch/xformers.git 'C:\Users\tobik\AppData\Local\Temp\pip-install-gax_br8z\xformers_5eb9f324d43041db94297bbeec3c496d'
  Cloning into 'C:\Users\tobik\AppData\Local\Temp\pip-install-gax_br8z\xformers_5eb9f324d43041db94297bbeec3c496d'...
  Updating files:   0% (2/591)
  Updating files:   1% (6/591)
  Updating files: 100% (591/591)
  Updating files: 100% (591/591), done.
  Running command git show-ref main
  40d39673285217d9c6b9a0e01e8809a10b771209 refs/heads/main
  40d39673285217d9c6b9a0e01e8809a10b771209 refs/remotes/origin/main
  Running command git symbolic-ref -q HEAD
  refs/heads/main
  Resolved https://github.com/facebookresearch/xformers.git to commit 40d39673285217d9c6b9a0e01e8809a10b771209
  Running command git submodule update --init --recursive -q
  Running command git rev-parse HEAD
  40d39673285217d9c6b9a0e01e8809a10b771209
  Running command python setup.py egg_info
  Traceback (most recent call last):
    File "<string>", line 2, in <module>
    File "<pip-setuptools-caller>", line 34, in <module>
    File "C:\Users\tobik\AppData\Local\Temp\pip-install-gax_br8z\xformers_5eb9f324d43041db94297bbeec3c496d\setup.py", line 398, in <module>
      extensions, extensions_metadata = get_extensions()
                                        ^^^^^^^^^^^^^^^^
    File "C:\Users\tobik\AppData\Local\Temp\pip-install-gax_br8z\xformers_5eb9f324d43041db94297bbeec3c496d\setup.py", line 270, in get_extensions
      cuda_version = get_cuda_version(CUDA_HOME)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\tobik\AppData\Local\Temp\pip-install-gax_br8z\xformers_5eb9f324d43041db94297bbeec3c496d\setup.py", line 111, in get_cuda_version
      raw_output = subprocess.check_output([nvcc_bin, "-V"], universal_newlines=True)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Program Files\Python311\Lib\subprocess.py", line 466, in check_output
      return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Program Files\Python311\Lib\subprocess.py", line 548, in run
      with Popen(*popenargs, **kwargs) as process:
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Program Files\Python311\Lib\subprocess.py", line 1026, in __init__
      self._execute_child(args, executable, preexec_fn, close_fds,
    File "C:\Program Files\Python311\Lib\subprocess.py", line 1538, in _execute_child
      hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  FileNotFoundError: [WinError 2] The system cannot find the file specified
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> See above for output.

  note: This error originates from a subprocess, and is likely not a problem with pip.
  full command: 'C:\Program Files\Python311\python.exe' -c '
  exec(compile('"'"''"'"''"'"'
  # This is <pip-setuptools-caller> -- a caller that pip uses to run setup.py
  #
  # - It imports setuptools before invoking setup.py, to enable projects that directly
  #   import from `distutils.core` to work with newer packaging standards.
  # - It provides a clear error message when setuptools is not installed.
  # - It sets `sys.argv[0]` to the underlying `setup.py`, when invoking `setup.py` so
  #   setuptools doesn'"'"'t think the script is `-c`. This avoids the following warning:
  #     manifest_maker: standard file '"'"'-c'"'"' not found".
  # - It generates a shim setup.py, for handling setup.cfg-only projects.
  import os, sys, tokenize

  try:
      import setuptools
  except ImportError as error:
      print(
          "ERROR: Can not execute `setup.py` since setuptools is not available in "
          "the build environment.",
          file=sys.stderr,
      )
      sys.exit(1)

  __file__ = %r
  sys.argv[0] = __file__

  if os.path.exists(__file__):
      filename = __file__
      with tokenize.open(__file__) as f:
          setup_py_code = f.read()
  else:
      filename = "<auto-generated setuptools caller>"
      setup_py_code = "from setuptools import setup; setup()"

  exec(compile(setup_py_code, filename, "exec"))
  '"'"''"'"''"'"' % ('"'"'C:\\Users\\tobik\\AppData\\Local\\Temp\\pip-install-gax_br8z\\xformers_5eb9f324d43041db94297bbeec3c496d\\setup.py'"'"',), "<pip-setuptools-caller>", "exec"))' egg_info --egg-base 'C:\Users\tobik\AppData\Local\Temp\pip-pip-egg-info-j3dm0_wl'
  cwd: C:\Users\tobik\AppData\Local\Temp\pip-install-gax_br8z\xformers_5eb9f324d43041db94297bbeec3c496d\
  Preparing metadata (setup.py) ... error
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.

T0biasCZe avatar Dec 11 '23 19:12 T0biasCZe

Hi, It looks like cuda (or at least NVCC) is not correctly installed.

danthe3rd avatar Dec 18 '23 14:12 danthe3rd

it is correctly installed image

T0biasCZe avatar Dec 18 '23 16:12 T0biasCZe

Do you have a $CUDA_HOME env variable set by any chance? You can check the detected cuda location with the following:

python -c "from torch.utils.cpp_extension import CUDA_HOME; print(CUDA_HOME)"

danthe3rd avatar Dec 19 '23 11:12 danthe3rd