Remove the dependency on CUDA SDk's version.txt (#5155)

This commit is contained in:
Changming Sun 2020-09-14 14:25:28 -07:00 committed by GitHub
parent 20b2f45b24
commit 8946d212bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -962,80 +962,6 @@ def setup_cuda_vars(args):
.format(
cuda_home, cuda_home_valid, cudnn_home, cudnn_home_valid))
# Our CI build machines already have the env vars setup
if is_windows() and 'AGENT_VERSION' not in os.environ:
# Validate that the cudnn_home is pointing at
# the right level.
if not os.path.exists(os.path.join(cudnn_home, "bin")):
raise BuildError(
"cudnn_home path should include the 'cuda' folder, and "
"must contain the CUDNN 'bin' directory.",
"cudnn_home='{}'".format(cudnn_home))
os.environ["CUDA_PATH"] = cuda_home
os.environ["CUDA_TOOLKIT_ROOT_DIR"] = cuda_home
cuda_bin_path = os.path.join(cuda_home, 'bin')
os.environ["CUDA_BIN_PATH"] = cuda_bin_path
os.environ["PATH"] += (os.pathsep + cuda_bin_path + os.pathsep +
os.path.join(cudnn_home, 'bin'))
# Add version specific CUDA_PATH_Vx_y value as the
# Visual Studio build files require that.
version_file = os.path.join(cuda_home, 'version.txt')
if not os.path.exists(version_file):
raise BuildError(
"No version file found in CUDA install directory. "
"Looked for " + version_file)
cuda_major_version = "unknown"
with open(version_file) as f:
# First line of version file should have something
# like 'CUDA Version 9.2.148'.
first_line = f.readline()
m = re.match(r"CUDA Version (\d+).(\d+)", first_line)
if not m:
raise BuildError(
"Couldn't read version from first line of " +
version_file)
cuda_major_version = m.group(1)
minor = m.group(2)
os.environ["CUDA_PATH_V{}_{}".format(
cuda_major_version, minor)] = cuda_home
vc_ver_str = os.getenv("VCToolsVersion") or ""
vc_ver = vc_ver_str.split(".")
if len(vc_ver) != 3:
log.warning(
"Unable to automatically verify VS 2017 toolset is "
"compatible with CUDA. Will attempt to use.")
log.warning(
"Failed to get valid Visual C++ Tools version from "
"VCToolsVersion environment variable value of '" +
vc_ver_str + "'")
log.warning(
"VCToolsVersion is set in a VS 2017 Developer Command "
"shell, or by running "
"'%VS2017INSTALLDIR%\\VC\\Auxiliary\\Build\\vcvars64.bat'")
log.warning(
"See build.md in the root ONNXRuntime directory for "
"instructions on installing the Visual C++ 2017 14.11 "
"toolset if needed.")
elif (cuda_major_version == "9" and vc_ver[0] == "14" and
int(vc_ver[1]) > 11):
raise BuildError(
"Visual C++ Tools version not supported by CUDA v9. You "
"must setup the environment to use the 14.11 toolset.",
"Current version is {}. CUDA 9.2 requires version "
"14.11.*".format(vc_ver_str), "If necessary manually "
"install the 14.11 toolset using the Visual Studio 2017 "
"updater.", "See 'Windows CUDA Build' in "
"build.md in the root directory of this repository.")
# TODO: check if cuda_version >=10.1, when cuda is enabled
# and VS version >=2019.
return cuda_home, cudnn_home