fix-l4-gpu-support

#3
by harshinde - opened
Files changed (3) hide show
  1. Dockerfile +8 -12
  2. helpers/TextSearch.py +1 -3
  3. requirements.txt +4 -3
Dockerfile CHANGED
@@ -15,34 +15,30 @@ ENV HOME=/home/user \
15
  WORKDIR /home/user/app
16
 
17
  # 4. Create Conda Env
18
- RUN conda create -n app_env python=3.9 wget -y
19
-
20
- # 5. Install Faiss via Conda (Pinned MKL)
21
- # This handles the "libmkl_intel_lp64.so.1" error
22
- RUN conda install -n app_env -c pytorch -c nvidia -c conda-forge faiss-gpu=1.7.4 mkl=2021 blas=1.0=mkl -y && \
23
  conda clean -ya
24
 
25
- # 6. Install Pip Requirements
26
  COPY requirements.txt .
27
  # This runs as root and creates a root-owned /home/user/.cache
28
  RUN pip install --no-cache-dir --upgrade pip && \
29
  pip install --no-cache-dir -r requirements.txt
30
 
31
- # 7. Fix Permissions (THE FIX)
32
  # We recursively chown the ENTIRE home directory.
33
- # This fixes the root-owned .cache folder created by pip in step 6.
34
  RUN chown -R user:user /home/user
35
 
36
- # 8. Switch to User
37
  USER user
38
 
39
- # 9. Download Files
40
  RUN wget https://huggingface.co/datasets/Major-TOM/Core-S2RGB-SigLIP/resolve/main/extras/faiss/viewer-app/siglip_ivfpq.index -O siglip_ivfpq.index && \
41
  wget https://huggingface.co/datasets/Major-TOM/Core-S2RGB-SigLIP/resolve/main/extras/faiss/viewer-app/siglip_ivfpq_metadata.parquet -O siglip_ivfpq_metadata.parquet
42
 
43
- # 10. Copy App Code
44
  COPY --chown=user *.py *.css ./
45
  COPY --chown=user helpers/* ./helpers/
46
 
47
- # 11. Entrypoint
48
  ENTRYPOINT ["solara", "run", "app.py", "--host=0.0.0.0", "--port", "7860", "--production"]
 
15
  WORKDIR /home/user/app
16
 
17
  # 4. Create Conda Env
18
+ RUN conda create -n app_env python=3.11 wget -y && \
 
 
 
 
19
  conda clean -ya
20
 
21
+ # 5. Install Pip Requirements
22
  COPY requirements.txt .
23
  # This runs as root and creates a root-owned /home/user/.cache
24
  RUN pip install --no-cache-dir --upgrade pip && \
25
  pip install --no-cache-dir -r requirements.txt
26
 
27
+ # 6. Fix Permissions (THE FIX)
28
  # We recursively chown the ENTIRE home directory.
29
+ # This fixes the root-owned .cache folder created by pip in step 5.
30
  RUN chown -R user:user /home/user
31
 
32
+ # 7. Switch to User
33
  USER user
34
 
35
+ # 8. Download Files
36
  RUN wget https://huggingface.co/datasets/Major-TOM/Core-S2RGB-SigLIP/resolve/main/extras/faiss/viewer-app/siglip_ivfpq.index -O siglip_ivfpq.index && \
37
  wget https://huggingface.co/datasets/Major-TOM/Core-S2RGB-SigLIP/resolve/main/extras/faiss/viewer-app/siglip_ivfpq_metadata.parquet -O siglip_ivfpq_metadata.parquet
38
 
39
+ # 9. Copy App Code
40
  COPY --chown=user *.py *.css ./
41
  COPY --chown=user helpers/* ./helpers/
42
 
43
+ # 10. Entrypoint
44
  ENTRYPOINT ["solara", "run", "app.py", "--host=0.0.0.0", "--port", "7860", "--production"]
helpers/TextSearch.py CHANGED
@@ -28,9 +28,7 @@ class SearchSigLIP():
28
  self.device = 'cuda' if torch.cuda.is_available() and faiss.get_num_gpus() > 0 else 'cpu'
29
  if self.device == 'cuda':
30
  res = faiss.StandardGpuResources()
31
- cloner_options = faiss.GpuClonerOptions()
32
- cloner_options.useFloat16LookupTables = True
33
- self.index = faiss.index_cpu_to_gpu(res, 0, self.cpu_index, cloner_options)
34
  self.index.nprobe = 32 # Higher = more accurate, slower
35
  else:
36
  self.index = self.cpu_index
 
28
  self.device = 'cuda' if torch.cuda.is_available() and faiss.get_num_gpus() > 0 else 'cpu'
29
  if self.device == 'cuda':
30
  res = faiss.StandardGpuResources()
31
+ self.index = faiss.index_cpu_to_gpu(res, 0, self.cpu_index)
 
 
32
  self.index.nprobe = 32 # Higher = more accurate, slower
33
  else:
34
  self.index = self.cpu_index
requirements.txt CHANGED
@@ -3,10 +3,10 @@ mapwidget
3
  solara
4
  geopandas
5
  fsspec
6
- pyarrow
7
  shapely
8
  pandas
9
- numpy
10
 
11
  torch==2.1.2
12
  torchvision==0.16.2
@@ -21,4 +21,5 @@ duckdb==1.0.0
21
  open_clip_torch==2.23.0
22
  transformers==4.46.3
23
  scikit-learn
24
- s3fs
 
 
3
  solara
4
  geopandas
5
  fsspec
6
+ pyarrow<18
7
  shapely
8
  pandas
9
+ numpy<2.0.0
10
 
11
  torch==2.1.2
12
  torchvision==0.16.2
 
21
  open_clip_torch==2.23.0
22
  transformers==4.46.3
23
  scikit-learn
24
+ s3fs
25
+ faiss-gpu-cu12