Merge pull request #4670 from awsr/subprocess

Update subprocess usage
This commit is contained in:
Vladimir Mandic
2026-03-08 20:10:14 +01:00
committed by GitHub
5 changed files with 56 additions and 59 deletions
+2 -2
View File
@@ -104,8 +104,8 @@ def get_gpu_info():
elif torch.cuda.is_available() and torch.version.cuda:
try:
import subprocess
result = subprocess.run('nvidia-smi --query-gpu=driver_version --format=csv,noheader', shell=True, check=False, env=os.environ, capture_output=True)
version = result.stdout.decode(encoding="utf8", errors="ignore").strip()
result = subprocess.run('nvidia-smi --query-gpu=driver_version --format=csv,noheader', shell=True, check=False, env=os.environ, capture_output=True, text=True)
version = result.stdout.strip()
return version
except Exception:
return ''
+2 -2
View File
@@ -31,8 +31,8 @@ def dirname(path_: str, r: int = 1) -> str:
def spawn(command: str | list[str], cwd: os.PathLike = '.') -> str:
process = subprocess.run(command, cwd=cwd, shell=True, check=False, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
return process.stdout.decode(encoding="utf8", errors="ignore")
process = subprocess.run(command, cwd=cwd, shell=True, check=False, capture_output=True, text=True)
return process.stdout
def load_library_global(path_: str):