-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathos_setup.py
122 lines (98 loc) · 4.42 KB
/
os_setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#-------------------------------------------------------------------#
# BatchWhisper-Transcription-Translation [LOCAL & API] #
#-------------------------------------------------------------------#
# Author: SABIAN HIBBS #
# License: MIT #
# Version: 3.5 #
#-------------------------------------------------------------------#
import shutil
import subprocess
import requests
import platform
import os
from zipfile import ZipFile
from pathlib import Path
def windows_install():
print("System detected: Windows")
print("\nRunning Blanket Install for Windows 10\n")
try:
print("Testing Cuda Availability")
subprocess.run(['nvidia-smi'])
except:
print("Cuda Not Installed")
"""Cuda 11.8 Installation"""
print("\nAttempting to install Cuda 11.8")
download_dir = os.getcwd() # Use the current working directory or specify another
filename = "cuda_11.8.0_522.06_windows.exe"
url = "https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda_11.8.0_522.06_windows.exe"
download_and_install_cuda_w(url, filename, download_dir)
try:
print("Conda Version:\n")
subprocess.run(["conda", "--version"])
except:
print("Conda Not Installed\n Run windows_setup.bat as Admin")
print("Testing for git")
try:
subprocess.run(['conda', '--version'])
except:
subprocess.run(['conda', 'install', 'git', '-y'])
print("\nInstalling Whisper from OpenAI\n")
subprocess.run(['pip', 'install', 'git+https://github.com/openai/whisper.git'])
subprocess.run(['pip', 'install', '--upgrade', '--no-deps', '--force-reinstall', 'git+https://github.com/openai/whisper.git'])
print("\nUpgrading PyTorch...")
subprocess.run(['pip', 'install', 'torch', 'torchvision', 'torchaudio', '--index-url', 'https://download.pytorch.org/whl/cu118'])
print("\nSetup Complete, Creating Directory")
# Create the directories if they don't exist
if not os.path.exists('Input-Videos'):
os.mkdir('Input-Videos')
print("\nDownload Complete: Follow Instructions with CUDA for your system.")
print("\nPlease 'Restart' computer for changes to be saved once CUDA has finished installing.")
def mac_install():
print("System detected: Mac OS")
def linux_install():
print("System detected: Linux")
def download_and_install_cuda_w(url: str, filename: str, download_dir: str) -> None:
"""Downloads CUDA installer from the specified URL to the given directory,
and then executes a silent installation."""
# Ensure the download directory exists
os.makedirs(download_dir, exist_ok=True)
# Download the file
print("Downloading CUDA installer...")
response = requests.get(url)
installer_path = os.path.join(download_dir, filename)
with open(installer_path, 'wb') as file:
file.write(response.content)
print("Download complete.")
# Execute the installer silently
print("Installing CUDA...")
subprocess.Popen([installer_path, '/S', f'/D={download_dir}'], shell=True)
print("Installation started. Please wait for it to complete.")
def get_os_variable():
system, node, release, version, machine, processor = platform.uname()
os_name = platform.system()
if os_name == "Windows":
# Extracting major version number for Windows
major_version = version.split('.')[2]
return f'w_{major_version}'
elif os_name == "Darwin":
# MacOS version can be found directly in `release`
return f'm_{release}'
elif os_name == "Linux":
# Optionally handle Linux differently; here we use the kernel release
return f'l_{release}'
else:
return f'other_{release}'
if __name__ == "__main__":
os_variable = get_os_variable()
print(os_variable)
if os_variable.startswith('w_'):
print("The system is running Windows.")
windows_install()
elif os_variable.startswith('m_'):
print("The system is running macOS.")
mac_install()
elif os_variable.startswith('l_'):
print("The system is running Linux.")
linux_install()
else:
print("The operating system is unknown or not supported.")