idiap / fast-transformers

Pytorch library for fast transformer implementations
1.63k stars 175 forks source link

Cannot install fast-transformers (Win10, Torch 1.6.0) #43

Open FilipAndersson245 opened 3 years ago

FilipAndersson245 commented 3 years ago

When I try to install fast-transformers i get the following error LOG_FILE_PIP.txt this after running pip install pytorch-fast-transformers --log LOG_FILE_PIP

The packages I have installed can be seen here packages.txt

FilipAndersson245 commented 3 years ago

The problem seems to occur in hash_cuda.cu

FAILED: C:/Users/Filip/AppData/Local/Temp/pip-install-f_hqurw5/pytorch-fast-transformers/build/temp.win-amd64-3.8/Release/fast_transformers/hashing/hash_cuda.obj
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin\nvcc -Xcompiler /MD -Xcompiler /wd4819 -Xcompiler /wd4251 -Xcompiler /wd4244 -Xcompiler /wd4267 -Xcompiler /wd4275 -Xcompiler /wd4018 -Xcompiler /wd4190 -Xcompiler /EHsc -Xcudafe --diag_suppress=base_class_has_different_dll_interface -Xcudafe --diag_suppress=field_without_dll_interface -Xcudafe --diag_suppress=dll_interface_conflict_none_assumed -Xcudafe --diag_suppress=dll_interface_conflict_dllexport_assumed -IC:\ProgramData\Anaconda3\lib\site-packages\torch\include -IC:\ProgramData\Anaconda3\lib\site-packages\torch\include\torch\csrc\api\include -IC:\ProgramData\Anaconda3\lib\site-packages\torch\include\TH -IC:\ProgramData\Anaconda3\lib\site-packages\torch\include\THC "-IC:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\include" -IC:\ProgramData\Anaconda3\include -IC:\ProgramData\Anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.27.29110\include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt" -c C:\Users\Filip\AppData\Local\Temp\pip-install-f_hqurw5\pytorch-fast-transformers\fast_transformers\hashing\hash_cuda.cu -o C:\Users\Filip\AppData\Local\Temp\pip-install-f_hqurw5\pytorch-fast-transformers\build\temp.win-amd64-3.8\Release\fast_transformers/hashing/hash_cuda.obj -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr -arch=compute_50 -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=hash_cuda -D_GLIBCXX_USE_CXX11_ABI=0
C:/ProgramData/Anaconda3/lib/site-packages/torch/include\c10/util/ThreadLocalDebugInfo.h(12): warning: modifier is ignored on an enum specifier

C:/ProgramData/Anaconda3/lib/site-packages/torch/include\ATen/record_function.h(18): warning: modifier is ignored on an enum specifier

C:/ProgramData/Anaconda3/lib/site-packages/torch/include\torch/csrc/jit/api/module.h(483): error: a member with an in-class initializer must be const

C:/ProgramData/Anaconda3/lib/site-packages/torch/include\torch/csrc/jit/api/module.h(496): error: a member with an in-class initializer must be const

C:/ProgramData/Anaconda3/lib/site-packages/torch/include\torch/csrc/jit/api/module.h(510): error: a member with an in-class initializer must be const

C:/ProgramData/Anaconda3/lib/site-packages/torch/include\torch/csrc/jit/api/module.h(523): error: a member with an in-class initializer must be const

C:/ProgramData/Anaconda3/lib/site-packages/torch/include\torch/csrc/autograd/profiler.h(97): warning: modifier is ignored on an enum specifier

C:/ProgramData/Anaconda3/lib/site-packages/torch/include\torch/csrc/autograd/profiler.h(126): warning: modifier is ignored on an enum specifier

4 errors detected in the compilation of "C:/Users/Filip/AppData/Local/Temp/tmpxft_00003864_00000000-10_hash_cuda.cpp1.ii".
hash_cuda.cu
ninja: build stopped: subcommand failed.
bratao commented 3 years ago

Try with pytorch 1.7.0

FilipAndersson245 commented 3 years ago

@bratao I just did a clean install of my Anaconda environment, upgraded to PyTorch 1.7, still the same issue. The error seem to have changed to the following:

    C:/ProgramData/Anaconda3/lib/site-packages/torch/include\c10/util/ThreadLocalDebugInfo.h(12): warning: modifier is ignored on an enum specifier

    C:/ProgramData/Anaconda3/lib/site-packages/torch/include\ATen/core/boxing/impl/boxing.h(100): warning: integer conversion resulted in a change of sign

    C:/ProgramData/Anaconda3/lib/site-packages/torch/include\ATen/record_function.h(13): warning: modifier is ignored on an enum specifier

    C:/ProgramData/Anaconda3/lib/site-packages/torch/include\ATen/core/op_registration/op_whitelist.h(39): warning: integer conversion resulted in a change of sign

    C:/ProgramData/Anaconda3/lib/site-packages/torch/include\torch/csrc/jit/ir/ir.h(1347): error: member "torch::jit::ProfileOptionalOp::Kind" may not be initialized

    C:/ProgramData/Anaconda3/lib/site-packages/torch/include\torch/csrc/autograd/profiler.h(106): warning: modifier is ignored on an enum specifier

    C:/ProgramData/Anaconda3/lib/site-packages/torch/include\torch/csrc/autograd/profiler.h(138): warning: modifier is ignored on an enum specifier

    C:/ProgramData/Anaconda3/lib/site-packages/torch/include/torch/csrc/api/include\torch/nn/modules/transformerlayer.h(73): warning: extra ";" ignored

    C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.27.29110/include\xutility(4387): error: function "torch::OrderedDict<Key, Value>::Item::operator=(const torch::OrderedDict<std::string, at::Tensor>::Item &) [with Key=std::string, Value=at::Tensor]" (declared implicitly) cannot be referenced -- it is a deleted function
              detected during:
                instantiation of "_OutIt std::_Move_unchecked1(_InIt, _InIt, _OutIt, std::false_type) [with _InIt=torch::OrderedDict<std::string, at::Tensor>::Item *, _OutIt=torch::OrderedDict<std::string, at::Tensor>::Item *]"
    (4403): here
                instantiation of "_OutIt std::_Move_unchecked(_InIt, _InIt, _OutIt) [with _InIt=torch::OrderedDict<std::string, at::Tensor>::Item *, _OutIt=torch::OrderedDict<std::string, at::Tensor>::Item *]"
    C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.27.29110/include\vector(1353): here
                instantiation of "std::vector<_Ty, _Alloc>::iterator std::vector<_Ty, _Alloc>::erase(std::vector<_Ty, _Alloc>::const_iterator) [with _Ty=torch::OrderedDict<std::string, at::Tensor>::Item, _Alloc=std::allocator<torch::OrderedDict<std::string, at::Tensor>::Item>]"
    C:/ProgramData/Anaconda3/lib/site-packages/torch/include\torch/csrc/api/include/torch/ordered_dict.h(419): here
                instantiation of "void torch::OrderedDict<Key, Value>::erase(const Key &) [with Key=std::string, Value=at::Tensor]"
    C:/ProgramData/Anaconda3/lib/site-packages/torch/include/torch/csrc/api/include\torch/nn/modules/container/parameterdict.h(51): here

    2 errors detected in the compilation of "C:/Users/Filip/AppData/Local/Temp/tmpxft_000008f4_00000000-10_hash_cuda.cpp1.ii".
    hash_cuda.cu
    ninja: build stopped: subcommand failed.
    Traceback (most recent call last):
      File "C:\ProgramData\Anaconda3\lib\site-packages\torch\utils\cpp_extension.py", line 1516, in _run_ninja_build
        subprocess.run(
      File "C:\ProgramData\Anaconda3\lib\subprocess.py", line 512, in run
        raise CalledProcessError(retcode, process.args,
    subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.

    The above exception was the direct cause of the following exception:

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\Filip\AppData\Local\Temp\pip-install-o__ie13g\pytorch-fast-transformers\setup.py", line 209, in <module>
        setup_package()
      File "C:\Users\Filip\AppData\Local\Temp\pip-install-o__ie13g\pytorch-fast-transformers\setup.py", line 182, in setup_package
        setup(
      File "C:\ProgramData\Anaconda3\lib\site-packages\setuptools\__init__.py", line 165, in setup
        return distutils.core.setup(**attrs)
      File "C:\ProgramData\Anaconda3\lib\distutils\core.py", line 148, in setup
        dist.run_commands()
      File "C:\ProgramData\Anaconda3\lib\distutils\dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "C:\ProgramData\Anaconda3\lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "C:\ProgramData\Anaconda3\lib\site-packages\setuptools\command\install.py", line 61, in run
        return orig.install.run(self)
      File "C:\ProgramData\Anaconda3\lib\distutils\command\install.py", line 545, in run
        self.run_command('build')
      File "C:\ProgramData\Anaconda3\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "C:\ProgramData\Anaconda3\lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "C:\ProgramData\Anaconda3\lib\distutils\command\build.py", line 135, in run
        self.run_command(cmd_name)
      File "C:\ProgramData\Anaconda3\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "C:\ProgramData\Anaconda3\lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "C:\ProgramData\Anaconda3\lib\site-packages\setuptools\command\build_ext.py", line 87, in run
        _build_ext.run(self)
      File "C:\ProgramData\Anaconda3\lib\site-packages\Cython\Distutils\old_build_ext.py", line 186, in run
        _build_ext.build_ext.run(self)
      File "C:\ProgramData\Anaconda3\lib\distutils\command\build_ext.py", line 340, in run
        self.build_extensions()
      File "C:\ProgramData\Anaconda3\lib\site-packages\torch\utils\cpp_extension.py", line 653, in build_extensions
        build_ext.build_extensions(self)
      File "C:\ProgramData\Anaconda3\lib\site-packages\Cython\Distutils\old_build_ext.py", line 195, in build_extensions
        _build_ext.build_ext.build_extensions(self)
      File "C:\ProgramData\Anaconda3\lib\distutils\command\build_ext.py", line 449, in build_extensions
        self._build_extensions_serial()
      File "C:\ProgramData\Anaconda3\lib\distutils\command\build_ext.py", line 474, in _build_extensions_serial
        self.build_extension(ext)
      File "C:\ProgramData\Anaconda3\lib\site-packages\setuptools\command\build_ext.py", line 208, in build_extension
        _build_ext.build_extension(self, ext)
      File "C:\ProgramData\Anaconda3\lib\distutils\command\build_ext.py", line 528, in build_extension
        objects = self.compiler.compile(sources,
      File "C:\ProgramData\Anaconda3\lib\site-packages\torch\utils\cpp_extension.py", line 626, in win_wrap_ninja_compile
        _write_ninja_file_and_compile_objects(
      File "C:\ProgramData\Anaconda3\lib\site-packages\torch\utils\cpp_extension.py", line 1233, in _write_ninja_file_and_compile_objects
        _run_ninja_build(
      File "C:\ProgramData\Anaconda3\lib\site-packages\torch\utils\cpp_extension.py", line 1538, in _run_ninja_build
        raise RuntimeError(message) from e
    RuntimeError: Error compiling objects for extension
    Error in atexit._run_exitfuncs:
    Traceback (most recent call last):
      File "C:\ProgramData\Anaconda3\lib\site-packages\colorama\ansitowin32.py", line 59, in closed
        return stream.closed
    ValueError: underlying buffer has been detached
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\ProgramData\Anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Filip\\AppData\\Local\\Temp\\pip-install-o__ie13g\\pytorch-fast-transformers\\setup.py'"'"'; __file__='"'"'C:\\Users\\Filip\\AppData\\Local\\Temp\\pip-install-o__ie13g\\pytorch-fast-transformers\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\Filip\AppData\Local\Temp\pip-record-nps69upz\install-record.txt' --single-version-externally-managed --user --prefix= --compile --install-headers 'C:\Users\Filip\AppData\Roaming\Python\Python38\Include\pytorch-fast-transformers' Check the logs for full command output.

Created a Pastebin with all the output when trying to install using pip install --user PyTorch-fast-transformers https://pastebin.com/eVxMh6A4

Is it possible to install pre-built binaries for fast-transformers somewhere?

angeloskath commented 3 years ago

Hi @FilipAndersson245, unfortunately, I do not have access to a Windows machine so neither can I ensure that it builds correctly nor provide prebuilt binaries.

I would say that @bratao is the resident Windows expert (thanks for that) so you are in good hands.

Let me know if there is anything else that I can help with.

Best, Angelos

bratao commented 3 years ago

@FilipAndersson245 sorry but I cannot help you as, because I cannot reproduce the error. The error is during the compilation of the cuda kernel. The thing is, the cuda + pytorch support in Windows in not very good. I usually try to use the naive version of fast-transformer on Windows, without cuda.

But according to this issue, https://github.com/pytorch/pytorch/pull/41554#issuecomment-665358333 If you delete the offending function in torch/ordered_dict.h, it will work.

GregorKobsik commented 3 years ago

@bratao Nice crosslink/issue!

Sadly, it does not help in my case, and I am not really tempted to fix linker errors (,yet).

As far as I understand it, according to commit eed8f756b0191ff73a2ef632696222555906e15d on 'PyTorch' the following change in ordered_dict.h should fix it, but it does not help in my case. I also could not find a comment on a successful workaround.

// NB: Move works by default, because you can move-construct vectors of const
// values. I tried to make this noexcept (conditional on the move constructors
// of index_ and items_ being noexcept) but the obvious spelling didn't
// compile on Windows.
OrderedDict(OrderedDict &&other) = default;
// OrderedDict &operator=(OrderedDict &&other) = default;

Following the tree further 'ParameterDirct', as well as Module uses 'OrderedDict' with operator=, thus commenting it out, should lead to further errors, as this function is used.

There is a chance, that I will look for a workaround. I will update on this issue, whether I was successful or not.

Windows 10 Python 3.8.6 CUDA 10.1 PyTorch 1.7.0+cu101

GregorKobsik commented 3 years ago

No fix, but a workaround for my workflow:

I use a remote Linux host, which I can access over SSH. More precisely, I use VS Code with Remote - SSH, which allows me to work on Windows and execute/compile code on Linux.

Another workaround could be WSL2, but sadly, as of today, the direct GPU support works only in the prerelease version. The installation of Linux on WSL2 in build 213222 freezes with my hardware setup, therefore I am not able to confirm, if this might be a viable workaround for someone.

p-sodmann commented 3 years ago

I am having the same issue, win 10, python 3.8, pytorch 1.7.1 as well as 1.8.1 tested. Can we at least get a wheel for the current pytorch version for python 3.8 and 3.9?

[EDIT] It tourned out, that I had some old cuda installations on my hard disk that were used, I was not aware, bcause i installed them a long time ago for Tensorflow. I also disabled the line from the fix and it worked. I will later try to generate a wheel out of it.

p-sodmann commented 3 years ago

Here is a zipped version of my binary it uses pytorch 1.8.1 with cuda 11.1

pytorch_fast_transformers-0.3.0-cp37-cp37m-win_amd64.zip

zerolfq commented 1 year ago

When I try to install fast-transformers i get the following error LOG_FILE_PIP.txt this after running pip install pytorch-fast-transformers --log LOG_FILE_PIP

The packages I have installed can be seen here packages.txt

Have you worked it out? I have the same problem

zerolfq commented 1 year ago

Here is a zipped version of my binary it uses pytorch 1.8.1 with cuda 11.1

pytorch_fast_transformers-0.3.0-cp37-cp37m-win_amd64.zip

Are you have pytorch-fast-transformers zipped version of binary uses py3.8 ?

PangHao-NEFU commented 1 year ago

same problem on win10:ERROR: Failed building wheel for pytorch-fast-transformers ERROR: Could not build wheels for pytorch-fast-transformers, which is required to install pyproject.toml-based projects
failed

PangHao-NEFU commented 1 year ago

pip install setuptools==59.6 run this may fix this problem