Update app.py
Browse files
app.py
CHANGED
@@ -5,7 +5,21 @@ from transformers import AutoTokenizer,GenerationConfig
|
|
5 |
import torch
|
6 |
from peft import PeftModel
|
7 |
import spaces
|
|
|
|
|
|
|
|
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
"""
|
10 |
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
|
11 |
"""
|
@@ -74,7 +88,8 @@ def loadModel():
|
|
74 |
torch_dtype=torch.float16,
|
75 |
cache_dir=cache_dir,
|
76 |
device_map="auto",
|
77 |
-
load_in_8bit=True
|
|
|
78 |
)
|
79 |
#model = PeftModel.from_pretrained(
|
80 |
# model,
|
|
|
5 |
import torch
|
6 |
from peft import PeftModel
|
7 |
import spaces
|
8 |
+
import torch
|
9 |
+
|
10 |
+
num_gpus = torch.cuda.device_count()
|
11 |
+
print(f"Number of available GPUs: {num_gpus}")
|
12 |
|
13 |
+
# List details for each GPU
|
14 |
+
for i in range(num_gpus):
|
15 |
+
print(f"GPU {i}: {torch.cuda.get_device_name(i)}")
|
16 |
+
print(f" Total Memory: {torch.cuda.get_device_properties(i).total_memory / 1e9:.2f} GB")
|
17 |
+
print(f" CUDA Capability: {torch.cuda.get_device_properties(i).major}.{torch.cuda.get_device_properties(i).minor}")
|
18 |
+
for i in range(num_gpus):
|
19 |
+
print(f"GPU {i}: {torch.cuda.get_device_name(i)}")
|
20 |
+
print(f" Allocated Memory: {torch.cuda.memory_allocated(i) / 1e9:.2f} GB")
|
21 |
+
print(f" Cached Memory: {torch.cuda.memory_reserved(i) / 1e9:.2f} GB")
|
22 |
+
print(f" Free Memory: {torch.cuda.get_device_properties(i).total_memory / 1e9 - torch.cuda.memory_reserved(i) / 1e9:.2f} GB")
|
23 |
"""
|
24 |
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
|
25 |
"""
|
|
|
88 |
torch_dtype=torch.float16,
|
89 |
cache_dir=cache_dir,
|
90 |
device_map="auto",
|
91 |
+
load_in_8bit=True,
|
92 |
+
load_in_8bit_fp32_cpu_offload=True
|
93 |
)
|
94 |
#model = PeftModel.from_pretrained(
|
95 |
# model,
|