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

Add Windows support for MSVC compiler path search #17

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions dnnlib/tflib/custom_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

compiler_bindir_search_path = [
'C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.14.26428/bin/Hostx64/x64',
'C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64',
'C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.23.28105/bin/Hostx64/x64',
'C:/Program Files (x86)/Microsoft Visual Studio 14.0/vc/bin',
]
Expand All @@ -34,9 +35,18 @@
# Internal helper funcs.

def _find_compiler_bindir():

#Derive MSVC compiler path from compiler_bindir_search_path array
for compiler_path in compiler_bindir_search_path:
if os.path.isdir(compiler_path):
return compiler_path

#Derive MSVC compiler path from subdirectory tree
subdirectory_paths = [x[0] for x in os.walk('C:\\Program Files (x86)\\Microsoft Visual Studio\\')];
if subdirectory_paths is not None:
for directory_path in subdirectory_paths:
if _compiler_path_validator(directory_path):
return directory_path
return None

def _get_compute_cap(device):
Expand Down Expand Up @@ -79,6 +89,16 @@ def _prepare_nvcc_cli(opts):
cmd += ' 2>&1'
return cmd

def _compiler_path_validator(path):
if path is not None:
if path[:76] == 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\' and path[-16:] == '\\bin\\Hostx64\\x64':
return True
elif path[:76] == 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\' and path[-16:] == '\\bin\\Hostx64\\x64':
return True
elif path == 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\vc\\bin':
return True
return False

#----------------------------------------------------------------------------
# Main entry point.

Expand Down