Fall back to asking nvcc for detecting cuda version if no *cudaart* is found (#19741)

Summary:
This happens on Debian/Ubuntu with distribution-provided cuda repackaging.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/19741

Differential Revision: D15082550

Pulled By: soumith

fbshipit-source-id: 2ca39c6cdc9305896529b6fd537270116223cd6c
This commit is contained in:
Thomas Viehmann
2019-04-25 10:50:41 -07:00
committed by Facebook Github Bot
parent 5025d1d5e4
commit 556c8a300b

View File

@ -45,6 +45,11 @@ def find_cuda_version(cuda_home):
# which are files containing cudart
candidate_names = list(glob.glob(os.path.join(cuda_lib_path, '*cudart*')))
candidate_names = [os.path.basename(c) for c in candidate_names]
# if we didn't find any cudart, ask nvcc
if len(candidate_names) == 0:
proc = Popen(['nvcc', '--version'], stdout=PIPE, stderr=PIPE)
out, err = proc.communicate()
candidate_names = [out.decode().rsplit('V')[-1]]
# suppose version is MAJOR.MINOR.PATCH, all numbers
version_regex = re.compile(r'[0-9]+\.[0-9]+\.[0-9]+')