Spaces:
Runtime error
Runtime error
Commit ·
0fcc024
1
Parent(s): 0b73ff0
updated reqquirements for flash
Browse files- app.py +7 -4
- requirements.txt +1 -0
app.py
CHANGED
|
@@ -7,6 +7,8 @@ import os
|
|
| 7 |
import random
|
| 8 |
import re
|
| 9 |
import subprocess
|
|
|
|
|
|
|
| 10 |
|
| 11 |
# Define the model name
|
| 12 |
OUTPUT_DIR = "output"
|
|
@@ -20,10 +22,12 @@ tokenizer = AutoTokenizer.from_pretrained(model_name)
|
|
| 20 |
# Load the model (without Flash Attention)
|
| 21 |
model = AutoModelForCausalLM.from_pretrained(
|
| 22 |
model_name,
|
| 23 |
-
torch_dtype=torch.float16, #
|
| 24 |
-
device_map="auto"
|
|
|
|
|
|
|
| 25 |
)
|
| 26 |
-
|
| 27 |
# Use torch.compile() only if supported (some environments may not support it)
|
| 28 |
try:
|
| 29 |
model = torch.compile(model, mode="max-autotune") # Optimize inference performance
|
|
@@ -78,7 +82,6 @@ emotion_keywords = {
|
|
| 78 |
"curious": ["curious", "wonder", "question", "thinking"],
|
| 79 |
"thoughtful": ["sad", "thoughtful", "hmm", "ponder", "upset"],
|
| 80 |
"concerned": ["error", "wrong", "problem", "issue", "stuck"],
|
| 81 |
-
"mischievous": ["trouble", "mischief", "sneaky", "prank"],
|
| 82 |
"naughty": ["sexy", "naughty", "slut", "bad girl","slutty", "tease", "whore", "cum", "tits", "ass", "shake", "tail", "pussy" ]
|
| 83 |
}
|
| 84 |
|
|
|
|
| 7 |
import random
|
| 8 |
import re
|
| 9 |
import subprocess
|
| 10 |
+
torch.cuda.empty_cache() # Clears unused GPU memory
|
| 11 |
+
torch.cuda.memory_allocated() # Checks available GPU memory
|
| 12 |
|
| 13 |
# Define the model name
|
| 14 |
OUTPUT_DIR = "output"
|
|
|
|
| 22 |
# Load the model (without Flash Attention)
|
| 23 |
model = AutoModelForCausalLM.from_pretrained(
|
| 24 |
model_name,
|
| 25 |
+
torch_dtype=torch.float16, # ✅ Keeps precision while reducing memory usage
|
| 26 |
+
device_map="auto", # ✅ Auto-allocates GPU/CPU memory
|
| 27 |
+
attn_implementation="triton", # ✅ Uses Triton for faster inference
|
| 28 |
+
low_cpu_mem_usage=True # ✅ Reduces RAM usage
|
| 29 |
)
|
| 30 |
+
torch.backends.cuda.matmul.allow_tf32 = True
|
| 31 |
# Use torch.compile() only if supported (some environments may not support it)
|
| 32 |
try:
|
| 33 |
model = torch.compile(model, mode="max-autotune") # Optimize inference performance
|
|
|
|
| 82 |
"curious": ["curious", "wonder", "question", "thinking"],
|
| 83 |
"thoughtful": ["sad", "thoughtful", "hmm", "ponder", "upset"],
|
| 84 |
"concerned": ["error", "wrong", "problem", "issue", "stuck"],
|
|
|
|
| 85 |
"naughty": ["sexy", "naughty", "slut", "bad girl","slutty", "tease", "whore", "cum", "tits", "ass", "shake", "tail", "pussy" ]
|
| 86 |
}
|
| 87 |
|
requirements.txt
CHANGED
|
@@ -6,6 +6,7 @@ accelerate
|
|
| 6 |
spaces
|
| 7 |
bitsandbytes
|
| 8 |
autoawq
|
|
|
|
| 9 |
transformers>=4.37.0
|
| 10 |
|
| 11 |
|
|
|
|
| 6 |
spaces
|
| 7 |
bitsandbytes
|
| 8 |
autoawq
|
| 9 |
+
triton
|
| 10 |
transformers>=4.37.0
|
| 11 |
|
| 12 |
|