Skip to content

Commit 67d8d61

Browse files
authored
Update whispers2t_batch_gui.py
Make setting cuda-related paths more robust.
1 parent 8f4ec19 commit 67d8d61

File tree

1 file changed

+24
-11
lines changed

1 file changed

+24
-11
lines changed

whispers2t_batch_gui.py

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,29 @@
2626
from whispers2t_batch_transcriber import Worker
2727

2828
def set_cuda_paths():
29-
try:
30-
venv_base = Path(sys.executable).parent
31-
nvidia_base_path = venv_base / 'Lib' / 'site-packages' / 'nvidia'
32-
for env_var in ['CUDA_PATH', 'CUDA_PATH_V12_1', 'PATH']:
33-
current_path = os.environ.get(env_var, '')
34-
os.environ[env_var] = os.pathsep.join(filter(None, [str(nvidia_base_path), current_path]))
35-
logging.info("CUDA paths set successfully")
36-
except Exception as e:
37-
logging.error(f"Error setting CUDA paths: {str(e)}")
38-
logging.debug(traceback.format_exc())
29+
venv_base = Path(sys.executable).parent.parent
30+
nvidia_base_path = venv_base / 'Lib' / 'site-packages' / 'nvidia'
31+
cuda_path = nvidia_base_path / 'cuda_runtime' / 'bin'
32+
cublas_path = nvidia_base_path / 'cublas' / 'bin'
33+
cudnn_path = nvidia_base_path / 'cudnn' / 'bin'
34+
paths_to_add = [str(cuda_path), str(cublas_path), str(cudnn_path)]
35+
env_vars = ['CUDA_PATH', 'CUDA_PATH_V12_1', 'PATH']
36+
37+
# print(f"Virtual environment base: {venv_base}")
38+
# print(f"NVIDIA base path: {nvidia_base_path}")
39+
# print(f"CUDA path: {cuda_path}")
40+
# print(f"cuBLAS path: {cublas_path}")
41+
# print(f"cuDNN path: {cudnn_path}")
42+
43+
for env_var in env_vars:
44+
current_value = os.environ.get(env_var, '')
45+
new_value = os.pathsep.join(paths_to_add + [current_value] if current_value else paths_to_add)
46+
os.environ[env_var] = new_value
47+
# print(f"\n{env_var} updated:")
48+
# print(f" Old value: {current_value}")
49+
# print(f" New value: {new_value}")
50+
51+
# print("\nCUDA paths have been set or updated in the environment variables.")
3952

4053
set_cuda_paths()
4154

@@ -221,4 +234,4 @@ def workerFinished(self, message):
221234
app.setStyle("Fusion")
222235
mainWindow = MainWindow()
223236
mainWindow.show()
224-
sys.exit(app.exec())
237+
sys.exit(app.exec())

0 commit comments

Comments
 (0)