Skip to content

Commit

Permalink
v6.0.2
Browse files Browse the repository at this point in the history
perfect set cuda path
  • Loading branch information
BBC-Esq authored Jul 1, 2024
1 parent 2bc2a17 commit d1d90c6
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions src/gui.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
import sys
import os
from pathlib import Path

def set_cuda_paths():
script_dir = Path(__file__).parent.resolve()
cuda_path = script_dir / 'Lib' / 'site-packages' / 'nvidia'
cublas_path = cuda_path / 'cublas' / 'bin'
cudnn_path = cuda_path / 'cudnn' / 'bin'

paths_to_add = [str(cuda_path), str(cublas_path), str(cudnn_path)]

env_vars = ['CUDA_PATH', 'CUDA_PATH_V12_2', 'PATH']

for env_var in env_vars:
current_value = os.environ.get(env_var, '')
new_value = os.pathsep.join(paths_to_add + [current_value] if current_value else paths_to_add)
os.environ[env_var] = new_value

print("CUDA paths have been set or updated in the environment variables.")

# Execute the function immediately
set_cuda_paths()

from PySide6.QtWidgets import (
QApplication, QWidget, QVBoxLayout, QTabWidget,
QStyleFactory, QMenuBar
Expand All @@ -11,24 +32,6 @@
from gui_tabs import create_tabs
from utilities import list_theme_files, make_theme_changer, load_stylesheet

def set_cuda_paths():
venv_base = Path(sys.executable).parent
nvidia_base_path = venv_base / 'Lib' / 'site-packages' / 'nvidia'
cudnn_bin_path = nvidia_base_path / 'cudnn' / 'bin'

# Set CUDA_PATH and CUDA_PATH_V12_2
for env_var in ['CUDA_PATH', 'CUDA_PATH_V12_2']:
current_path = os.environ.get(env_var, '')
os.environ[env_var] = os.pathsep.join(filter(None, [str(nvidia_base_path), current_path]))

# Add nvidia folder and cudnn bin folder to system PATH
current_path = os.environ.get('PATH', '')
new_path = os.pathsep.join(filter(None, [str(cudnn_bin_path), str(nvidia_base_path), current_path]))
os.environ['PATH'] = new_path

set_cuda_paths()


class DocQA_GUI(QWidget):
def __init__(self):
super().__init__()
Expand Down

0 comments on commit d1d90c6

Please sign in to comment.