in install_cuda.py [0:0]
def install_cuda(version, base_path, download_path):
formatted_version = f"{version[:-1]}.{version[-1]}"
folder = f"cuda-{formatted_version}"
install_path = os.path.join(base_path, folder)
if os.path.exists(install_path):
print(f"Removing existing CUDA version {version} at {install_path}...")
subprocess.run(["rm", "-rf", install_path], check=True)
url = cuda_versions[version]
filename = url.split("/")[-1]
filepath = os.path.join(download_path, filename)
if not os.path.exists(filepath):
print(f"Downloading CUDA version {version} from {url}...")
urlretrieve(url, filepath)
else:
print(f"Installer for CUDA version {version} already downloaded.")
# Make the installer executable
subprocess.run(["chmod", "+x", filepath], check=True)
# Install CUDA
print(f"Installing CUDA version {version}...")
install_command = [
"bash",
filepath,
"--no-drm",
"--no-man-page",
"--override",
"--toolkitpath=" + install_path,
"--toolkit",
"--silent",
]
print(f"Running command: {' '.join(install_command)}")
try:
subprocess.run(install_command, check=True)
except subprocess.CalledProcessError as e:
print(f"Installation failed for CUDA version {version}: {e}")
return
finally:
# Delete the installer file
os.remove(filepath)
print(f"CUDA version {version} installed at {install_path}")