jina-ai / executor-text-transformers-torch-encoder

**TransformerTorchEncoder** wraps the torch-version of transformers from huggingface. It encodes text data into dense vectors.
9 stars 2 forks source link

No matching distribution found for torch==1.9.0+cpu #15

Open heyarny opened 1 year ago

heyarny commented 1 year ago

I'm trying to get this to work on my macbook pro m1 max, but no matter what I do I get this error when trying to run it locally.

Unpacking TransformerTorchEncoder ...ERROR: Could not find a version that satisfies the requirement torch==1.9.0+cpu (from versions: 1.8.0, 1.8.1, 1.9.0, 1.10.0, 1.10.1, 1.10.2, 1.11.0, 1.12.0, 1.12.1, 1.13.0)
ERROR: No matching distribution found for torch==1.9.0+cpu

Anyone know how to fix this?

JoanFM commented 1 year ago

Have u tried following these steps?

https://towardsdatascience.com/installing-pytorch-on-apple-m1-chip-with-gpu-acceleration-3351dc44d67c

It seems to be something related to Pytorch.

We are looking into updating jina and docarray versions in conda

heyarny commented 1 year ago

Yes, according to the documentation my torch is using "mps" which is GPU supported.

Output of:

import torch
import math

# this ensures that the current MacOS version is at least 12.3+
print(torch.backends.mps.is_available())
# this ensures that the current current PyTorch installation was built with MPS activated.
print(torch.backends.mps.is_built())
True
True

This is my small setup:

flow.yml:

jtype: Flow
version: '1'
with:
  port: 54321
executors:
  - name: encoder
    uses: 'jinahub://TransformerTorchEncoder/latest-gpu'
    volumes: '.cache/huggingface:/root/.cache/huggingface'
    install_requirements: true
  - name: PrintExecutor
    uses: print_executor/config.yml

Full output:

jina flow --uses flow.yml 

MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWWWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMWNNNNNNNWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMNNNNNNNNNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMWNNNNNNNNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWNNNWWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMWxxxxxxxxxOMMMMMNxxxxxxxxx0MMMMMKddddddxkKWMMMMMMMMMMMMXOxdddxONMMMM
MMMMMMMMMMMMXllllllllldMMMMM0lllllllllxMMMMMOllllllllllo0MMMMMMMM0olllllllllo0MM
MMMMMMMMMMMMXllllllllldMMMMM0lllllllllxMMMMMOlllllllllllloWMMMMMdllllllllllllldM
MMMMMMMMMMMMXllllllllldMMMMM0lllllllllxMMMMMOllllllllllllloMMMM0lllllllllllllllK
MMMMMMMMMMMMKllllllllldMMMMM0lllllllllxMMMMMOllllllllllllllKMMM0lllllllllllllllO
MMMMMMMMMMMMKllllllllldMMMMM0lllllllllxMMMMMOllllllllllllll0MMMMollllllllllllllO
MWOkkkkk0MMMKlllllllllkMMMMM0lllllllllxMMMMMOllllllllllllll0MMMMMxlllllllllllllO
NkkkkkkkkkMMKlllllllloMMMMMM0lllllllllxMMMMMOllllllllllllll0MMMMMMWOdolllllllllO
KkkkkkkkkkNMKllllllldMMMMMMMMWWWWWWWWWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MOkkkkkkk0MMKllllldXMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMWX00KXMMMMXxk0XMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM

/opt/homebrew/bin/jina flow --uses flow.yml        
╭──────────────┬──────────────────────────────────╮
│     Argument │ Value                            │
├──────────────┼──────────────────────────────────┤
│          cli │ flow                             │
│          env │ None                             │
│      inspect │ COLLECT                          │
│   log-config │ default                          │
│         name │ None                             │
│        quiet │ False                            │
│  quiet-error │ False                            │
│         uses │ flow.yml                         │
│    workspace │ None                             │
│ workspace-id │ 21f44c96c2de40f18d25158412a956d4 │
╰──────────────┴──────────────────────────────────╯
⠙ Installing dependencies from requirements.txt...Looking in links: https://download.pytorch.org/whl/torch_stable.html
⠴ Installing dependencies from requirements.txt...ERROR: Could not find a version that satisfies the requirement torch==1.9.0+cpu (from versions: 1.11.0, 1.12.0, 1.12.1, 1.13.0)
ERROR: No matching distribution found for torch==1.9.0+cpu
Traceback (most recent call last):
  File "/opt/homebrew/bin/jina", line 8, in <module>
    sys.exit(main())
  File "/opt/homebrew/lib/python3.10/site-packages/jina_cli/__init__.py", line 143, in main
    getattr(api, args.cli.replace('-', '_'))(args)
  File "/opt/homebrew/lib/python3.10/site-packages/jina_cli/api.py", line 169, in flow
    with f:
  File "/opt/homebrew/lib/python3.10/site-packages/jina/orchestrate/flow/base.py", line 1718, in __enter__
    return self.start()
  File "/opt/homebrew/lib/python3.10/site-packages/jina/orchestrate/flow/builder.py", line 33, in arg_wrapper
    return func(self, *args, **kwargs)
  File "/opt/homebrew/lib/python3.10/site-packages/jina/orchestrate/flow/base.py", line 1781, in start
    self.enter_context(deployment)
  File "/opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/contextlib.py", line 492, in enter_context
    result = _cm_type.__enter__(cm)
  File "/opt/homebrew/lib/python3.10/site-packages/jina/orchestrate/deployments/__init__.py", line 121, in __enter__
    return self.start()
  File "/opt/homebrew/lib/python3.10/site-packages/jina/orchestrate/deployments/__init__.py", line 668, in start
    self.enter_context(self.shards[shard_id])
  File "/opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/contextlib.py", line 492, in enter_context
    result = _cm_type.__enter__(cm)
  File "/opt/homebrew/lib/python3.10/site-packages/jina/orchestrate/deployments/__init__.py", line 232, in __enter__
    self._pods.append(PodFactory.build_pod(_args).start())
  File "/opt/homebrew/lib/python3.10/site-packages/jina/orchestrate/pods/factory.py", line 36, in build_pod
    cargs.uses = HubIO(_hub_args).pull()
  File "/opt/homebrew/lib/python3.10/site-packages/hubble/executor/hubio.py", line 1362, in pull
    install_package_dependencies(
  File "/opt/homebrew/lib/python3.10/site-packages/hubble/executor/hubapi.py", line 209, in install_package_dependencies
    install_requirements(requirements_file)
  File "/opt/homebrew/lib/python3.10/site-packages/hubble/executor/helper.py", line 719, in install_requirements
    subprocess.check_call(
  File "/opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/subprocess.py", line 369, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/opt/homebrew/opt/python@3.10/bin/python3.10', '-m', 'pip', 'install', '--compile', '--default-timeout=1000', 'torch==1.9.0+cpu', 'transformers>=4.12.0', '-f', 'https://download.pytorch.org/whl/torch_stable.html']' returned non-zero exit status 1.
jpzhangvincent commented 1 year ago

I think the requirements.txt needs to update the torch version. Otherwise, it would fail when using this executor.

JoanFM commented 1 year ago

@jpzhangvincent may u provide a PR with the required changes u consider?