ray-embedding 0.10.11__tar.gz → 0.10.15__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ray-embedding might be problematic. Click here for more details.
- {ray_embedding-0.10.11 → ray_embedding-0.10.15}/PKG-INFO +1 -1
- {ray_embedding-0.10.11 → ray_embedding-0.10.15}/ray_embedding/embedding_model.py +14 -3
- {ray_embedding-0.10.11 → ray_embedding-0.10.15}/ray_embedding.egg-info/PKG-INFO +1 -1
- {ray_embedding-0.10.11 → ray_embedding-0.10.15}/setup.cfg +1 -1
- {ray_embedding-0.10.11 → ray_embedding-0.10.15}/README.md +0 -0
- {ray_embedding-0.10.11 → ray_embedding-0.10.15}/pyproject.toml +0 -0
- {ray_embedding-0.10.11 → ray_embedding-0.10.15}/ray_embedding/__init__.py +0 -0
- {ray_embedding-0.10.11 → ray_embedding-0.10.15}/ray_embedding/deploy.py +0 -0
- {ray_embedding-0.10.11 → ray_embedding-0.10.15}/ray_embedding/dto.py +0 -0
- {ray_embedding-0.10.11 → ray_embedding-0.10.15}/ray_embedding.egg-info/SOURCES.txt +0 -0
- {ray_embedding-0.10.11 → ray_embedding-0.10.15}/ray_embedding.egg-info/dependency_links.txt +0 -0
- {ray_embedding-0.10.11 → ray_embedding-0.10.15}/ray_embedding.egg-info/top_level.txt +0 -0
|
@@ -7,6 +7,7 @@ import torch
|
|
|
7
7
|
from fastapi import FastAPI, HTTPException
|
|
8
8
|
from ray import serve
|
|
9
9
|
from sentence_transformers import SentenceTransformer
|
|
10
|
+
from pynvml import nvmlInit, nvmlDeviceGetCount
|
|
10
11
|
|
|
11
12
|
from ray_embedding.dto import EmbeddingResponse, EmbeddingRequest
|
|
12
13
|
|
|
@@ -37,7 +38,8 @@ class EmbeddingModel:
|
|
|
37
38
|
self.init_device = device
|
|
38
39
|
if self.init_device is None or self.init_device == "auto":
|
|
39
40
|
self.init_device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
40
|
-
self.
|
|
41
|
+
if self.init_device == "cuda":
|
|
42
|
+
self.wait_for_cuda()
|
|
41
43
|
self.torch_device = torch.device(self.init_device)
|
|
42
44
|
self.backend = backend or "torch"
|
|
43
45
|
self.matryoshka_dim = matryoshka_dim
|
|
@@ -99,9 +101,18 @@ class EmbeddingModel:
|
|
|
99
101
|
"""Returns the list of available models in OpenAI-compatible format."""
|
|
100
102
|
return {"object": "list", "data": self.available_models}
|
|
101
103
|
|
|
102
|
-
def
|
|
104
|
+
def wait_for_cuda(self, wait: int = 10):
|
|
103
105
|
if self.init_device == "cuda" and not torch.cuda.is_available():
|
|
106
|
+
time.sleep(wait)
|
|
107
|
+
self.check_health()
|
|
108
|
+
|
|
109
|
+
def check_health(self):
|
|
110
|
+
if self.init_device == "cuda":
|
|
104
111
|
# Even though CUDA was available at init time,
|
|
105
112
|
# CUDA can become unavailable - this is a known problem in AWS EC2
|
|
106
113
|
# https://github.com/ray-project/ray/issues/49594
|
|
107
|
-
|
|
114
|
+
try:
|
|
115
|
+
nvmlInit()
|
|
116
|
+
assert nvmlDeviceGetCount() >= 1
|
|
117
|
+
except:
|
|
118
|
+
raise RuntimeError("CUDA device is not available")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|