NemoVonNirgend commited on
Commit
1498531
·
verified ·
1 Parent(s): ee74ec9

Upload serve_ministral.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. serve_ministral.py +14 -5
serve_ministral.py CHANGED
@@ -8,17 +8,26 @@ import subprocess
8
  import sys
9
 
10
  def install_deps():
11
- deps = ["transformers", "accelerate", "fastapi", "uvicorn", "pydantic", "sentencepiece", "protobuf"]
12
  # Check if torch with CUDA exists, only install if missing
13
  try:
14
  import torch
15
- if not torch.cuda.is_available():
16
- deps.insert(0, "torch")
17
  except ImportError:
18
- deps.insert(0, "torch")
19
 
20
  print("=== Installing dependencies ===")
21
- subprocess.check_call([sys.executable, "-m", "pip", "install", "-U", "-q"] + deps)
 
 
 
 
 
 
 
 
 
 
 
22
  print("=== Dependencies installed ===")
23
 
24
  install_deps()
 
8
  import sys
9
 
10
  def install_deps():
 
11
  # Check if torch with CUDA exists, only install if missing
12
  try:
13
  import torch
14
+ need_torch = not torch.cuda.is_available()
 
15
  except ImportError:
16
+ need_torch = True
17
 
18
  print("=== Installing dependencies ===")
19
+
20
+ if need_torch:
21
+ subprocess.check_call([sys.executable, "-m", "pip", "install", "-q", "torch"])
22
+
23
+ # Install transformers from git for mistral3 support
24
+ subprocess.check_call([sys.executable, "-m", "pip", "install", "-q",
25
+ "git+https://github.com/huggingface/transformers.git"])
26
+
27
+ # Install other deps
28
+ subprocess.check_call([sys.executable, "-m", "pip", "install", "-q",
29
+ "accelerate", "fastapi", "uvicorn", "pydantic", "sentencepiece", "protobuf"])
30
+
31
  print("=== Dependencies installed ===")
32
 
33
  install_deps()