ford442 commited on
Commit
1dfa8b2
·
verified ·
1 Parent(s): f378894

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +58 -2
app.py CHANGED
@@ -10,8 +10,46 @@ os.environ["SAFETENSORS_FAST_GPU"] = "1"
10
 
11
  import subprocess
12
 
13
- result = subprocess.run(['nvidia-smi'], capture_output=True, text=True, check=True) # check=True raises an exception if the command fails
14
- print(result)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
  #subprocess.run(['sh', './torch.sh'])
17
 
@@ -691,6 +729,24 @@ title = "Text Generator Demo GPT-Neo"
691
  description = "Text Generator Application by ecarbo"
692
 
693
  if __name__ == "__main__":
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
694
  demo_interface = demo.queue(max_size=50) # Remove .launch() here
695
 
696
  text_gen_interface = gr.Interface(
 
10
 
11
  import subprocess
12
 
13
+ import re
14
+
15
+ def find_cuda_directories(search_paths=None):
16
+ """Finds directories that contain "cuda" and a version number in their name.
17
+
18
+ Args:
19
+ search_paths: A list of directories to search. If None, uses common paths.
20
+
21
+ Returns:
22
+ A dictionary where keys are directory paths and values are extracted versions.
23
+ Returns an empty dictionary if no CUDA directories are found.
24
+ """
25
+
26
+ if search_paths is None:
27
+ # Common CUDA installation locations (customize as needed)
28
+ search_paths = [
29
+ "/usr/local", # Linux
30
+ "/usr/lib", # Linux
31
+ "/opt", # Linux
32
+ "/Program Files", # Windows
33
+ "/Applications", # macOS (less common)
34
+ os.path.expanduser("~") # Check user's home directory
35
+ ]
36
+ if os.name == 'nt': #Windows
37
+ search_paths.append("C:\\Program Files")
38
+ search_paths.append("C:\\Program Files (x86)")
39
+
40
+ cuda_dirs = {}
41
+
42
+ for path in search_paths:
43
+ if os.path.exists(path): # Check if the path exists
44
+ for root, dirs, files in os.walk(path): # Walk recursively
45
+ for dir_name in dirs:
46
+ match = re.search(r"cuda(\d+(\.\d+)*)", dir_name, re.IGNORECASE) # Regex for cuda and version
47
+ if match:
48
+ full_path = os.path.join(root, dir_name)
49
+ version = match.group(1)
50
+ cuda_dirs[full_path] = version
51
+
52
+ return cuda_dirs
53
 
54
  #subprocess.run(['sh', './torch.sh'])
55
 
 
729
  description = "Text Generator Application by ecarbo"
730
 
731
  if __name__ == "__main__":
732
+
733
+ cuda_directories = find_cuda_directories()
734
+
735
+ if cuda_directories:
736
+ print("Found CUDA directories:")
737
+ for directory, version in cuda_directories.items():
738
+ print(f"- {directory}: Version {version}")
739
+ else:
740
+ print("No CUDA directories found in the specified paths.")
741
+
742
+
743
+
744
+ # Example of how to find the "best" CUDA path (customize logic)
745
+ if cuda_directories:
746
+ # Simple example: just pick the first one. You might have more sophisticated selection criteria
747
+ best_cuda_path = list(cuda_directories.keys())
748
+ print(f"Using CUDA path: {best_cuda_path}")
749
+
750
  demo_interface = demo.queue(max_size=50) # Remove .launch() here
751
 
752
  text_gen_interface = gr.Interface(