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

It is necessary to add this flag for compilation on Windows #45

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bburrough
Copy link

filtered_lrelu.cpp uses "if constexpr" which is c++17, and will otherwise fail with the following error.

filtered_lrelu.cpp(147): error C4984: 'if constexpr' is a C++17 language extension

Please note, I have not tested this on other platforms (e.g. Ubuntu), where this flag might be inappropriate.

…e, as filtered_lrelu.cpp uses "if constexpr" which is c++17, and will otherwise fail with the following error.

filtered_lrelu.cpp(147): error C4984: 'if constexpr' is a C++17 language extension
@bburrough
Copy link
Author

If you don't wish to adopt this flag, you might alternatively consider removing "if constexpr" for greater portability.

@PDillis
Copy link

PDillis commented Nov 22, 2021

I just tested this on Ubuntu 20.04 and it works, so the flag could be added in general to benefit Windows users.

PDillis added a commit to PDillis/stylegan3-fun that referenced this pull request Nov 23, 2021
@PDillis
Copy link

PDillis commented Nov 25, 2021

Actually, I just tested it again with another code (random interpolation in particular), and it fails. I recommend adding a os check as follows:

def _init():
    global _plugin
    # Bob Burrough's PR (#45) so that the plugins work in Windows: https://github.com/NVlabs/stylegan3/pull/45
    extras = {}
    if os.name == 'nt':
        extras['extra_cflags'] = ['/std:c++17']
    if _plugin is None:
        _plugin = custom_ops.get_plugin(
            module_name='filtered_lrelu_plugin',
            sources=['filtered_lrelu.cpp', 'filtered_lrelu_wr.cu', 'filtered_lrelu_rd.cu', 'filtered_lrelu_ns.cu'],
            headers=['filtered_lrelu.h', 'filtered_lrelu.cu'],
            source_dir=os.path.dirname(__file__),
            extra_cuda_cflags=['--use_fast_math'],
            **extras,
        )
    return True

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

Successfully merging this pull request may close these issues.

None yet

2 participants