Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
Signed-off-by: NickLucche <[email protected]>
  • Loading branch information
NickLucche committed Jan 22, 2025
1 parent 2e84efc commit 86e5339
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
18 changes: 10 additions & 8 deletions extras/print_gpu_memory_stats.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import torch


def print_gpu_memory_stats():
if not torch.cuda.is_available():
print("No GPU available")
return

for i in range(torch.cuda.device_count()):
device_name = torch.cuda.get_device_name(i)
# Convert to GB
total_memory = torch.cuda.get_device_properties(i).total_memory / (1024 ** 3)
allocated = torch.cuda.memory_allocated(i) / (1024 ** 3)
reserved = torch.cuda.memory_reserved(i) / (1024 ** 3)
max_allocated = torch.cuda.max_memory_allocated(i) / (1024 ** 3)
max_reserved = torch.cuda.max_memory_reserved(i) / (1024 ** 3)
total_memory = torch.cuda.get_device_properties(i).total_memory / (1024
**3)
allocated = torch.cuda.memory_allocated(i) / (1024**3)
reserved = torch.cuda.memory_reserved(i) / (1024**3)
max_allocated = torch.cuda.max_memory_allocated(i) / (1024**3)
max_reserved = torch.cuda.max_memory_reserved(i) / (1024**3)
free_memory = reserved - allocated

print(f"Device {i}: {device_name}")
print(f" Total Memory: {total_memory:.2f} GB")
print(f" Allocated Memory: {allocated:.2f} GB")
Expand All @@ -24,5 +26,5 @@ def print_gpu_memory_stats():
print(f" Max Reserved: {max_reserved:.2f} GB")
print("-" * 40)

print_gpu_memory_stats()

print_gpu_memory_stats()
4 changes: 2 additions & 2 deletions extras/smoke-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ curl -v --no-progress-meter --fail-with-body \
echo "OpenAI API success" && kill $server_pid && wait $server_pid
# In case `nvidia-smi` is missing
script_dir=$(dirname "$(realpath "$0")")
python $script_dir/print_gpu_memory_stats.py
python "$script_dir"/print_gpu_memory_stats.py

# spin up the grpc server in the background
python -m vllm_tgis_adapter --grpc-port $GRPC_PORT --model facebook/opt-125m --enforce-eager &
Expand All @@ -78,4 +78,4 @@ wait_for "grpc_server" grpc_healthcheck # healthcheck is part of vllm_tgis_adapt
echo "GRPC API success" && kill $server_pid && wait $server_pid
# In case `nvidia-smi` is missing
script_dir=$(dirname "$(realpath "$0")")
python $script_dir/print_gpu_memory_stats.py
python "$script_dir"/print_gpu_memory_stats.py

0 comments on commit 86e5339

Please sign in to comment.