-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
49 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import subprocess | ||
|
||
def write_pytorch_cuda_install_command(): | ||
try: | ||
result = subprocess.run(['nvcc', '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) | ||
if result.returncode == 0: | ||
# get cuda version | ||
cuda_version = result.stdout.split()[18].strip(",").strip(" ").replace(".", "") | ||
# build command | ||
pytorch_cuda_install = f"pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu{cuda_version} --upgrade" | ||
# write command to file | ||
with open(".\.pytorch_cuda_install_command.txt", "w") as f: | ||
f.write(pytorch_cuda_install) | ||
else: | ||
return False | ||
except Exception as e: | ||
print("An error occurred. Maybe you do not have CUDA installed", str(e)) | ||
return False | ||
|
||
if __name__ == "__main__": | ||
write_pytorch_cuda_install_command() |
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