Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build error on windows by vs2022 #2985

Open
3 tasks done
KFeiHe opened this issue Aug 3, 2023 · 4 comments
Open
3 tasks done

build error on windows by vs2022 #2985

KFeiHe opened this issue Aug 3, 2023 · 4 comments

Comments

@KFeiHe
Copy link

KFeiHe commented Aug 3, 2023

Summary

1>.../faiss-1.7.4\faiss/gpu/impl/PQCodeDistances-inl.cuh(541): error : expected an expression
1> auto outDistancesCodeViewCols = outCodeDistancesView.view<2>({coarseIndices.getSize(0) * coarseIndices.getSize(1),
1> ^
1>
1>1 error detected in the compilation of ".../faiss-1.7.4/faiss/gpu/impl/IVFPQ.cu".

Platform

OS: WIN11

Faiss version: 1.7.4

Installed from: just build for c++; cmake -B build . -DFAISS_ENABLE_PYTHON=OFF -DFAISS_ENABLE_GPU=ON -DFAISS_ENABLE_C_API=ON -DBUILD_SHARED_LIBS=ON

Faiss compilation options:

Running on:

  • CPU
  • GPU

Interface:

  • C++

Reproduction instructions

@mdouze
Copy link
Contributor

mdouze commented Aug 3, 2023

please do not post screenshots.

@mdouze
Copy link
Contributor

mdouze commented Aug 4, 2023

Although we don't support compiling GPU Faiss for windows, if there is an easy fix then we'd intergrate it. It seems that VC++ does not support some syntax here.

https://github.com/facebookresearch/faiss/blob/main/faiss/gpu/impl/PQCodeDistances-inl.cuh#L541

@wickedfoo any idea what's the issue here?

@yexiangyu
Copy link

create a personal dirty-hack to workaround this issue: https://github.com/yexiangyu/faiss/tree/v1.7.4-win

@APerson13
Copy link

If anybody else comes across this, I was able to solve this specific build error.

Before you compile, edit 2 lines in faiss/gpu/impl/PQCodeDistances-inl.cuh:

  • line 506: auto outCodeDistancesView = outCodeDistancesF.view<3>( -> auto outCodeDistancesView = outCodeDistancesF.template view<3>(
  • line 541: auto outDistancesCodeViewCols = outCodeDistancesView.view<2>( -> auto outDistancesCodeViewCols = outCodeDistancesView.template view<2>(

I am pretty inexperienced in C++, so I do not necessarily know if only one of these lines is necessary, but changing both lines worked for me and I'm too scared to touch it again.

A good explanation of why the template keyword makes an appearance here can be found in the Eigen docs. Basically, it can be ambiguous whether the angle brackets are comparison operators or template parameters. I think MSVC is expecting another expression to be compared to (outCodeDistancesView.view < 2) inside the brackets, so it throws an error because it finds an initializer list.

Worth pointing out that unless there is some way to bulk-dllimport everything in a header or something like that, the lack of __declspec(dllimport) in headers means that you still cannot link to a built shared library unless you want to manually update every header. I have yet to test building as a static library on Windows, but I could build a faiss.dll with GPU support seemingly fine on Windows, even if I cannot use it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants