in linux/cuda_installer/os_installers/__init__.py [0:0]
def verify_cuda(self) -> bool:
"""
Make sure that CUDA Toolkit is properly installed by compiling and executing CUDA code samples.
"""
logger.info("Verifying CUDA installation...")
with tempfile.TemporaryDirectory() as temp_dir:
temp_dir = pathlib.Path(temp_dir)
with chdir(temp_dir):
logger.info(
f"Using {temp_dir} to download, build and execute code samples."
)
samples_tar = self.download_file(
CUDA_SAMPLES_URL, CUDA_SAMPLES_SHA256_SUM, CUDA_SAMPLES_GS_URI
)
self.run(f"tar -xf {samples_tar.name}")
with chdir(temp_dir / f"cuda-samples-{CUDA_SAMPLES_VERSION}"):
self.run("cmake .", check=True)
with chdir(
temp_dir
/ f"cuda-samples-{CUDA_SAMPLES_VERSION}/Samples/1_Utilities/deviceQuery"
):
self.run("make", check=True)
dev_query = self.run("./deviceQuery", check=True)
if "Result = PASS" not in dev_query.stdout:
logger.error(
"Cuda Toolkit verification failed. DeviceQuery sample failed."
)
return False
with chdir(
temp_dir
/ f"cuda-samples-{CUDA_SAMPLES_VERSION}/Samples/1_Utilities/bandwidthTest"
):
self.run("make", check=True)
bandwidth = self.run("./bandwidthTest", check=True)
if "Result = PASS" not in bandwidth.stdout:
logger.error(
"Cuda Toolkit verification failed. BandwidthTest sample failed."
)
return False
logger.info("Cuda Toolkit verification completed!")
return True