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.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ray-embedding
3
- Version: 0.10.11
3
+ Version: 0.10.15
4
4
  Summary: Deploy SentenceTransformers embedding models to a ray cluster
5
5
  Author: Crispin Almodovar
6
6
  Author-email:
@@ -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.check_health()
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 check_health(self):
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
- raise RuntimeError("CUDA device is not available")
114
+ try:
115
+ nvmlInit()
116
+ assert nvmlDeviceGetCount() >= 1
117
+ except:
118
+ raise RuntimeError("CUDA device is not available")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ray-embedding
3
- Version: 0.10.11
3
+ Version: 0.10.15
4
4
  Summary: Deploy SentenceTransformers embedding models to a ray cluster
5
5
  Author: Crispin Almodovar
6
6
  Author-email:
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = ray-embedding
3
- version = 0.10.11
3
+ version = 0.10.15
4
4
  author = Crispin Almodovar
5
5
  author_email =
6
6
  description = Deploy SentenceTransformers embedding models to a ray cluster