Cleanup redundant SAM forward() methods (#4591)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Glenn Jocher 2023-08-27 19:19:13 +02:00 committed by GitHub
parent 47ab96dab6
commit 2567b288c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 118 deletions

View file

@ -519,9 +519,13 @@ def cuda_device_count() -> int:
# Run the nvidia-smi command and capture its output
output = subprocess.check_output(['nvidia-smi', '--query-gpu=count', '--format=csv,noheader,nounits'],
encoding='utf-8')
return int(output.strip())
except (subprocess.CalledProcessError, FileNotFoundError):
# If the command fails or nvidia-smi is not found, assume no GPUs are available
# Take the first line and strip any leading/trailing white space
first_line = output.strip().split('\n')[0]
return int(first_line)
except (subprocess.CalledProcessError, FileNotFoundError, ValueError):
# If the command fails, nvidia-smi is not found, or output is not an integer, assume no GPUs are available
return 0