Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When using prebuilt docker images and demo code, problems raised #797

Closed
Vision0220 opened this issue Aug 5, 2022 · 1 comment
Closed

Comments

@Vision0220
Copy link

When using prebuilt docker images and demo code, such problems raised:

code:

from clip_client import Client
clip_client = Client('grpc://0.0.0.0:51009')
r = clip_client.encode(['First do it', 'then do it right', 'then do it better']) # this will lead to errors
print(r.shape) # [3, 512]

docker command: docker run -p 51009:51000 -v $HOME/.cache:/home/cas/.cache --gpus all jinaai/clip-server
(seems working good, but cannot function

And the error looks like this:

ERROR clip_
t/rep-0@44 RuntimeError('expected scalar type [08/05/22 13:57:27]
Float but found Half')
add "--quiet-error" to suppress the exception
details
╭──────── Traceback (most recent call last) ────────╮
│ /usr/local/lib/python3.8/dist-packages/jina/serv… │
│ in process_data │
│ │
│ 161 │ │ │ │ if self.logger.debug_enable │
│ 162 │ │ │ │ │ self._log_data_request( │
│ 163 │ │ │ │ │
│ ❱ 164 │ │ │ │ return await self._data_req │
│ 165 │ │ │ except (RuntimeError, Exception │
│ 166 │ │ │ │ self.logger.error( │
│ 167 │ │ │ │ │ f'{ex!r}' │
│ │
│ /usr/local/lib/python3.8/dist-packages/jina/serv… │
│ in handle │
│ │
│ 152 │ │ ) │
│ 153 │ │ │
│ 154 │ │ # executor logic │
│ ❱ 155 │ │ return_data = await self._executor. │
│ 156 │ │ │ req_endpoint=requests[0].header │
│ 157 │ │ │ docs=docs, │
│ 158 │ │ │ parameters=params, │
│ │
│ /usr/local/lib/python3.8/dist-packages/jina/serv… │
│ in acall
│ │
│ 288 │ │ if req_endpoint in self.requests: │
│ 289 │ │ │ return await self.__acall_endpo │
│ 290 │ │ elif default_endpoint in self.r │
│ ❱ 291 │ │ │ return await self._acall_endpo │
│ 292 │ │
│ 293 │ async def acall_endpoint(self, req

│ 294 │ │ func = self.requests[req_endpoint] │
│ │
│ /usr/local/lib/python3.8/dist-packages/jina/serv… │
│ in acall_endpoint
│ │
│ 307 │ │ │
│ 308 │ │ with _summary: │
│ 309 │ │ │ if iscoroutinefunction(func): │
│ ❱ 310 │ │ │ │ return await func(self, **k │
│ 311 │ │ │ else: │
│ 312 │ │ │ │ return func(self, **kwargs) │
│ 313 │
│ │
│ /usr/local/lib/python3.8/dist-packages/jina/serv… │
│ in arg_wrapper │
│ │
│ 204 │ │ │ │ async def arg_wrapper( │
│ 205 │ │ │ │ │ executor_instance, *arg │
│ 206 │ │ │ │ ): # we need to get the su │
│ the self │
│ ❱ 207 │ │ │ │ │ return await fn(executo │
│ 208 │ │ │ │ │
│ 209 │ │ │ │ self.fn = arg_wrapper │
│ 210 │ │ │ else: │
│ │
│ /usr/local/lib/python3.8/dist-packages/clip_serv… │
│ in encode │
│ │
│ 138 │ │ │ │ │ │ documentation='text │
│ 139 │ │ │ │ │ ): │
│ 140 │ │ │ │ │ │ minibatch.embedding │
│ ❱ 141 │ │ │ │ │ │ │ self._model.enc │
│ 142 │ │ │ │ │ │ │ .cpu() │
│ 143 │ │ │ │ │ │ │ .numpy() │
│ 144 │ │ │ │ │ │ │ .astype(np.floa │
│ │
│ /usr/local/lib/python3.8/dist-packages/clip_serv… │
│ in encode_text │
│ │
│ 45 │ │ return model_name.replace('/', '-') │
│ 46 │ │
│ 47 │ def encode_text(self, input_ids: 'torch. │
│ ❱ 48 │ │ return self._model.encode_text(input │
│ 49 │ │
│ 50 │ def encode_image(self, pixel_values: 'to │
│ 51 │ │ return self._model.encode_image(pixe │
│ │
│ /usr/local/lib/python3.8/dist-packages/clip_serv… │
│ in encode_text │
│ │
│ 570 │ │ │
│ 571 │ │ x = x + self.positional_embedding.t │
│ 572 │ │ x = x.permute(1, 0, 2) # NLD -> LN │
│ ❱ 573 │ │ x = self.transformer(x, attn_mask=s │
│ 574 │ │ x = x.permute(1, 0, 2) # LND -> NL │
│ 575 │ │ x = self.ln_final(x).type(self.dtyp │
│ 576 │
│ │
│ /usr/local/lib/python3.8/dist-packages/torch/nn/… │
│ in _call_impl │
│ │
│ 1127 │ │ # this function, and just call for │
│ 1128 │ │ if not (self._backward_hooks or se │
│ or _global_backward_hooks │
│ 1129 │ │ │ │ or _global_forward_hooks o │
│ ❱ 1130 │ │ │ return forward_call(*input, ** │
│ 1131 │ │ # Do not call functions when jit i │
│ 1132 │ │ full_backward_hooks, non_full_back │
│ 1133 │ │ if self._backward_hooks or _global │
│ │
│ /usr/local/lib/python3.8/dist-packages/clip_serv… │
│ in forward │
│ │
│ 325 │ │ │ if self.grad_checkpointing and │
│ 326 │ │ │ │ x = checkpoint(r, x, attn_m │
│ 327 │ │ │ else: │
│ ❱ 328 │ │ │ │ x = r(x, attn_mask=attn_mas │
│ 329 │ │ return x │
│ 330 │
│ 331 │
│ │
│ /usr/local/lib/python3.8/dist-packages/torch/nn/… │
│ in _call_impl │
│ │
│ 1127 │ │ # this function, and just call for │
│ 1128 │ │ if not (self._backward_hooks or se │
│ or _global_backward_hooks │
│ 1129 │ │ │ │ or _global_forward_hooks o │
│ ❱ 1130 │ │ │ return forward_call(*input, ** │
│ 1131 │ │ # Do not call functions when jit i │
│ 1132 │ │ full_backward_hooks, non_full_back │
│ 1133 │ │ if self._backward_hooks or _global │
│ │
│ /usr/local/lib/python3.8/dist-packages/clip_serv… │
│ in forward │
│ │
│ 294 │ │ return self.attn(x, x, x, need_weig │
│ 295 │ │
│ 296 │ def forward(self, x: torch.Tensor, attn │
│ ❱ 297 │ │ x = x + self.attention(self.ln_1(x) │
│ 298 │ │ x = x + self.mlp(self.ln_2(x)) │
│ 299 │ │ return x │
│ 300 │
│ │
│ /usr/local/lib/python3.8/dist-packages/clip_serv… │
│ in attention │
│ │
│ 291 │ │ self.ln_2 = LayerNorm(d_model) │
│ 292 │ │
│ 293 │ def attention(self, x: torch.Tensor, at │
│ ❱ 294 │ │ return self.attn(x, x, x, need_weig │
│ 295 │ │
│ 296 │ def forward(self, x: torch.Tensor, attn │
│ 297 │ │ x = x + self.attention(self.ln_1(x) │
│ │
│ /usr/local/lib/python3.8/dist-packages/torch/nn/… │
│ in _call_impl │
│ │
│ 1127 │ │ # this function, and just call for │
│ 1128 │ │ if not (self._backward_hooks or se │
│ or _global_backward_hooks │
│ 1129 │ │ │ │ or _global_forward_hooks o │
│ ❱ 1130 │ │ │ return forward_call(*input, ** │
│ 1131 │ │ # Do not call functions when jit i │
│ 1132 │ │ full_backward_hooks, non_full_back │
│ 1133 │ │ if self.backward_hooks or global │
│ │
│ /usr/local/lib/python3.8/dist-packages/torch/nn/… │
│ in forward │
│ │
│ 1150 │ │ │ │ q_proj_weight=self.q_proj

│ 1151 │ │ │ │ v_proj_weight=self.v_proj

│ average_attn_weights=average_attn_weights) │
│ 1152 │ │ else: │
│ ❱ 1153 │ │ │ attn_output, attn_output_weigh │
│ 1154 │ │ │ │ query, key, value, self.em │
│ 1155 │ │ │ │ self.in_proj_weight, self. │
│ 1156 │ │ │ │ self.bias_k, self.bias_v, │
│ │
│ /usr/local/lib/python3.8/dist-packages/torch/nn/… │
│ in multi_head_attention_forward │
│ │
│ 5176 │ # │
│ 5177 │ # (deep breath) calculate attention an │
│ 5178 │ # │
│ ❱ 5179 │ attn_output, attn_output_weights = sc │
│ dropout_p) │
│ 5180 │ attn_output = attn_output.transpose(0, │
│ embed_dim) │
│ 5181 │ attn_output = linear(attn_output, out

│ 5182 │ attn_output = attn_output.view(tgt_len │
│ │
│ /usr/local/lib/python3.8/dist-packages/torch/nn/… │
│ in _scaled_dot_product_attention │
│ │
│ 4849 │ q = q / math.sqrt(E) │
│ 4850 │ # (B, Nt, E) x (B, E, Ns) -> (B, Nt, N │
│ 4851 │ if attn_mask is not None: │
│ ❱ 4852 │ │ attn = torch.baddbmm(attn_mask, q, │
│ 4853 │ else: │
│ 4854 │ │ attn = torch.bmm(q, k.transpose(-2 │
│ 4855 │
╰───────────────────────────────────────────────────╯
RuntimeError: expected scalar type Float but found
Half

@numb3r3
Copy link
Member

numb3r3 commented Aug 8, 2022

Thanks @Vision0220 for pointing it out. Fixed in #790. Pleas try it again.

@numb3r3 numb3r3 closed this as completed Aug 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants