Skip to content

Commit

Permalink
Merge pull request #583 from BoxMars/master
Browse files Browse the repository at this point in the history
Refactor get_cuda() function to check for CUDA version using nvcc command in PATH
  • Loading branch information
rbonghi authored Oct 10, 2024
2 parents 15e0521 + 913bbd4 commit 0cafe7e
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"], stdout=subprocess.DEVNULL) == 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 0cafe7e

Please sign in to comment.