Skip to content

Commit

Permalink
fix: remove process backend (#685)
Browse files Browse the repository at this point in the history
* fix: remove process backend

* fix: typo
  • Loading branch information
numb3r3 authored Apr 20, 2022
1 parent 65ad956 commit 71e9ebc
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 12 deletions.
1 change: 0 additions & 1 deletion docs/user-guides/server.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ For PyTorch & ONNX backend, you can set the following parameters via `with`:
| `name` | Model weights, default is `ViT-B/32`. Support all OpenAI released pretrained models. |
| `num_worker_preprocess` | The number of CPU workers for image & text prerpocessing, default 4. |
| `minibatch_size` | The size of a minibatch for CPU preprocessing and GPU encoding, default 64. Reduce the size of it if you encounter OOM on GPU. |
| `pool_backend` | The backend of the preprocessing worker pool, default is `thread` |

There are also runtime-specific parameters listed below:

Expand Down
7 changes: 2 additions & 5 deletions server/clip_server/executors/clip_onnx.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,15 @@ def __init__(
device: Optional[str] = None,
num_worker_preprocess: int = 4,
minibatch_size: int = 64,
pool_backend: str = 'thread',
**kwargs,
):
super().__init__(**kwargs)
self.logger = JinaLogger(self.__class__.__name__)

self._preprocess_blob = clip._transform_blob(_SIZE[name])
self._preprocess_tensor = clip._transform_ndarray(_SIZE[name])
if pool_backend == 'thread':
self._pool = ThreadPool(processes=num_worker_preprocess)
else:
self._pool = Pool(processes=num_worker_preprocess)
self._pool = ThreadPool(processes=num_worker_preprocess)

self._minibatch_size = minibatch_size

self._model = CLIPOnnxModel(name)
Expand Down
8 changes: 2 additions & 6 deletions server/clip_server/executors/clip_torch.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
import numpy as np
from multiprocessing.pool import ThreadPool, Pool
from multiprocessing.pool import ThreadPool
from typing import Optional, List, Tuple

from jina import Executor, requests, DocumentArray
Expand All @@ -17,7 +17,6 @@ def __init__(
jit: bool = False,
num_worker_preprocess: int = 4,
minibatch_size: int = 64,
pool_backend: str = 'thread',
**kwargs,
):
super().__init__(**kwargs)
Expand Down Expand Up @@ -51,10 +50,7 @@ def __init__(
name, device=self._device, jit=jit
)

if pool_backend == 'thread':
self._pool = ThreadPool(processes=num_worker_preprocess)
else:
self._pool = Pool(processes=num_worker_preprocess)
self._pool = ThreadPool(processes=num_worker_preprocess)

def _preproc_image(self, da: 'DocumentArray') -> 'DocumentArray':
for d in da:
Expand Down

0 comments on commit 71e9ebc

Please sign in to comment.