forked from iree-org/iree
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract and improve script to download CUDA toolkit components.
Previous to this, we were fetching a sample from an NVIDIA github repo and using CMake scripting to use it to download an appropriate SDK. This patch: * Forks the parse_redist.py sample locally into third_party/nvidia_sdk_download. * Fixes a number of things in parse_redist.py to make it more robust, remove warnings, and eliminate the dependency on the Python requests package. * Removes the 'requests' package from all requirements files as it is no longer needed. * Adds a fetch_cuda_toolkit.py which duplicates the behavior that was open coded in CMake scripting. * Updates the build_tools/third_party/cuda/CMakeLists.txt to use the new script instead of its internal approach. In a follow-on, I will use this script on the Bazel side to make it auto-fetch the CUDA SDK as needed as well.
- Loading branch information
Stella Laurenzo
committed
Mar 9, 2023
1 parent
6bc4084
commit d1a65a7
Showing
5 changed files
with
148 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,5 @@ requires = [ | |
"packaging", | ||
"pybind11>=2.10.1", | ||
"PyYAML", | ||
"requests", | ||
] | ||
build-backend = "setuptools.build_meta" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,5 @@ requires = [ | |
"packaging", | ||
"pybind11>=2.10.1", | ||
"PyYAML", | ||
"requests", | ||
] | ||
build-backend = "setuptools.build_meta" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright 2022 The IREE Authors | ||
# | ||
# Licensed under the Apache License v2.0 with LLVM Exceptions. | ||
# See https://llvm.org/LICENSE.txt for license information. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
"""Fetches components of the CUDA toolkit that we need to build. | ||
Syntax: | ||
fetch_cuda_toolkit.py {output_dir} | ||
This will download an appropriate toolkit (subset) and print the full path | ||
to the resulting directory (which will be a sub-directory of the output_dir). | ||
""" | ||
|
||
from pathlib import Path | ||
import platform | ||
import shutil | ||
import subprocess | ||
import sys | ||
|
||
VERSION = "11.6.2" | ||
PRODUCT = "cuda" | ||
COMPONENTS = ["cuda_nvcc", "cuda_cudart"] | ||
|
||
|
||
def main(output_dir: Path): | ||
system = platform.system() | ||
if system == "Linux": | ||
os = "linux" | ||
elif system == "Windows": | ||
os = "windows" | ||
else: | ||
print("ERROR: Fetching CUDA toolkit only supported on windows and linux") | ||
sys.exit(1) | ||
|
||
arch = platform.machine() | ||
if arch == "AMD64": | ||
arch = "x86_64" | ||
|
||
target_dir = output_dir / VERSION | ||
arch_dir = target_dir / f"{os}-{arch}" | ||
touch_file = arch_dir / "cuda_toolkit.downloaded" | ||
if touch_file.exists(): | ||
print(f"Not downloading because touch file exists: {touch_file}", | ||
file=sys.stderr) | ||
else: | ||
# Remove and create arch dir. | ||
if arch_dir.exists(): | ||
shutil.rmtree(arch_dir) | ||
arch_dir.mkdir(parents=True, exist_ok=True) | ||
|
||
for component in COMPONENTS: | ||
print(f"Downloading component {component}", file=sys.stderr) | ||
subprocess.check_call([ | ||
sys.executable, | ||
str(Path(__file__).resolve().parent / "parse_redist.py"), | ||
"--label", | ||
VERSION, | ||
"--product", | ||
PRODUCT, | ||
"--os", | ||
os, | ||
"--arch", | ||
arch, | ||
"--component", | ||
component, | ||
"--output", | ||
target_dir, | ||
], | ||
cwd=target_dir, | ||
stdout=sys.stderr) | ||
|
||
# Touch the file to note done. | ||
with open(touch_file, "w") as f: | ||
pass | ||
|
||
# Report back. | ||
print(arch_dir) | ||
|
||
|
||
if __name__ == "__main__": | ||
if len(sys.argv) != 2: | ||
print("ERROR: Expected output_dir", file=sys.stderr) | ||
sys.exit(1) | ||
main(Path(sys.argv[1])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters