Skip to content

Commit

Permalink
Refactor get_cuda() function to check for CUDA version using nvcc com…
Browse files Browse the repository at this point in the history
…mand in PATH
  • Loading branch information
BoxMars committed Oct 10, 2024
1 parent 15e0521 commit 8e0e710
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions jtop/core/jetson_libraries.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import os
import re
import subprocess
from .common import cat
from .command import Command
# Fix connection refused for python 2.7
Expand Down Expand Up @@ -49,6 +50,17 @@ def get_cuda():
break
except (OSError, Command.CommandException):
pass
elif subprocess.call(["which", "nvcc"]) == 0:
cmd = Command(['nvcc', '--version'])
try:
lines = cmd()
for line in lines:
match = re.search(CUDA_NVCC_RE, line)
if match:
cuda_version = match.group(1)
break
except (OSError, Command.CommandException):
pass
return cuda_version


Expand Down

0 comments on commit 8e0e710

Please sign in to comment.