ERROR: Could not find a version that satisfies the requirement torch==1.7.1+cpu
I’m (a NLP newbie) trying to use the zero-shot models on a system without a GPU. None of the models seem to work. Can this work without a CPU?example code:from transformers import pipelineclassifier = pipeline(“zero-shot-classification”, model=‘joeddav/xlm-roberta-large-xnli’, device=-1)sequence = “За кого вы голосуете в 2020 году?”candidate_labels = [“Europe”, “public health”, “politics”]classifier(sequence, candidate_labels)output:~/.local/lib/python3.8/site-packages/torch/cuda/init.py:52: UserWarning: CUDA initialization: Found no NVIDIA driver on your system. Please check that you have an NVIDIA GPU and installed a driver fromOfficial Drivers | NVIDIA(Triggered internally at  /pytorch/c10/cuda/CUDAFunctions.cpp:100.)return torch._C._cuda_getDeviceCount() > 0Some weights of the model checkpoint at joeddav/xlm-roberta-large-xnli were not used when initializing XLMRobertaForSequenceClassification: [‘roberta.pooler.dense.weight’, ‘roberta.pooler.dense.bias’]This IS expected if you are initializing XLMRobertaForSequenceClassification from the checkpoint of a model trained on another task or with another architecture (e.g. initializing a BertForSequenceClassification model from a BertForPreTraining model).This IS NOT expected if you are initializing XLMRobertaForSequenceClassification from the checkpoint of a model that you expect to be exactly identical (initializing a BertForSequenceClassification model from a BertForSequenceClassification model).
2020-12-11T10:02:35Z
Hi@waldennAll the models and pipelines can work on CPU.What you posted arewarnings which you can safely ignore.I think you have installed torch cuda versio on CPU machine, which is giving you the first warning
2020-12-11T10:21:55Z
Thanks, but I followed the docs saying:Alternatively, for CPU-support only, you can installTransformers and PyTorch in one line with:pip install transformers[torch]I previously also did:pip install transformers[tf-cpu]What do I need to install / configure to make the CPU-only work for zero-shot learning?FYI: The “pip list” output:Package                Versionabsl-py                0.11.0apsw                   3.28.0.post1apturl                 0.5.2astunparse             1.6.3beautifulsoup4         4.8.2blinker                1.4Brlapi                 0.7.0cachetools             4.1.1certifi                2019.11.28chardet                3.0.4chrome-gnome-shell     0.0.0cliapp                 1.20180812.1Click                  7.0cmdtest                0.32+gitcolorama               0.4.3command-not-found      0.3cryptography           2.8css-parser             1.0.4cssselect              1.1.0cssutils               1.0.2cupshelpers            1.0dataclasses            0.6dbus-python            1.2.16defer                  1.0.6distro                 1.4.0distro-info            0.23ubuntu1dnspython              1.16.0entrypoints            0.3feedparser             5.2.1filelock               3.0.12fire                   0.3.1future                 0.18.2gast                   0.3.3google-auth            1.23.0google-auth-oauthlib   0.4.2google-pasta           0.2.0grpcio                 1.34.0h5py                   2.10.0html2text              2020.1.16html5-parser           0.4.9html5lib               1.0.1httplib2               0.14.0httptools              0.1.1idna                   2.8ifaddr                 0.1.6joblib                 0.17.0Keras-Preprocessing    1.1.2keras2onnx             1.7.0keyring                18.0.1language-selector      0.1launchpadlib           1.10.13lazr.restfulclient     0.14.2lazr.uri               1.0.3louis                  3.12.0lxml                   4.5.0macaroonbakery         1.3.1Markdown               3.1.1mechanize              0.4.5msgpack                0.6.2netifaces              0.10.4nose                   1.3.7numpy                  1.19.4oauthlib               3.1.0olefile                0.46onnx                   1.8.0onnxconverter-common   1.7.0opt-einsum             3.3.0packaging              20.3pexpect                4.6.0Pillow                 7.0.0pip                    20.0.2protobuf               3.6.1pyasn1                 0.4.8pyasn1-modules         0.2.8pycairo                1.16.2pychm                  0.8.6pycups                 1.9.73Pygments               2.3.1PyGObject              3.36.0PyJWT                  1.7.1pymacaroons            0.13.0PyNaCl                 1.3.0pyparsing              2.4.6PyQt5                  5.14.1PyQtWebEngine          5.14.0pyRFC3339              1.1python-apt             2.0.0+ubuntu0.20.4.2python-dateutil        2.7.3python-debian          0.1.36ubuntu1pytz                   2019.3pyxdg                  0.26PyYAML                 5.3.1regex                  2019.8.19reportlab              3.5.34repoze.lru             0.7requests               2.22.0requests-oauthlib      1.3.0requests-unixsocket    0.2.0Routes                 2.4.1rsa                    4.6sacremoses             0.0.43SecretStorage          2.3.1sentencepiece          0.1.94setuptools             45.2.0simplejson             3.16.0sip                    4.19.21six                    1.14.0soupsieve              1.9.5systemd-python         234tensorboard            2.4.0tensorboard-plugin-wit 1.7.0tensorflow-cpu         2.3.1tensorflow-estimator   2.3.0termcolor              1.1.0tokenizers             0.9.4torch                  1.7.0tqdm                   4.54.1transformers           4.0.1ttystatus              0.38typing-extensions      3.7.4.3ubuntu-advantage-tools 20.3ubuntu-drivers-common  0.0.0ufw                    0.36unattended-upgrades    0.1urllib3                1.25.8wadllib                1.3.3webencodings           0.5.1WebOb                  1.8.5Werkzeug               1.0.1wheel                  0.34.2wrapt                  1.12.1xkit                   0.0.0zeroconf               0.24.4
2020-12-11T10:27:25Z
You could just uninstall the torch gpu version and the install cpu onepip uninstall torchto uninstallandpip install torch==1.7.1+cputo install torch cpu
2020-12-11T10:31:33Z
valhalla:pip install torch==1.7.1+cpuOk, I for the second command I get this error:pip install torch==1.7.0+cpuERROR: Could not find a version that satisfies the requirement torch==1.7.0+cpu (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2, 1.4.0, 1.5.0, 1.5.1, 1.6.0, 1.7.0, 1.7.1)ERROR: No matching distribution found for torch==1.7.0+cpu$ python --versionPython 3.8.5
2020-12-11T10:32:26Z
I get the same error for the 1.7.1 version.
2020-12-11T10:35:20Z
$ lsb_release -aNo LSB modules are available.Distributor ID:	UbuntuDescription:	Ubuntu 20.04.1 LTSRelease:	20.04Codename:	focal
2020-12-11T10:36:43Z
these arewarnings, are you able to see the output ofclassifier(sequence, candidate_labels)?
2020-12-11T10:51:49Z
No, not for the zeroshot learning code.The basic transformer command also showed the CUDA warning, but gave correct output.python -c “from transformers import pipeline; print(pipeline(‘sentiment-analysis’)(‘we love you’))”
2020-12-11T16:54:28Z
If someone knows how to fix this, please let me know. Thanks!pip install torch==1.7.0+cpuERROR: Could not find a version that satisfies the requirement torch==1.7.0+cpu (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2, 1.4.0, 1.5.0, 1.5.1, 1.6.0, 1.7.0, 1.7.1)ERROR: No matching distribution found for torch==1.7.0+cpu
2020-12-13T09:51:51Z
I would advice you to just set up a fresh python environment using the latest conda-distribution and then do pip install transformers and it should work. I have set up multiple non-GPU VMs (both Amazon Linux and Ubuntu) in the last week that way and it has worked without any mucking around with either torch or cuda-versions.
2020-12-13T10:10:22Z
For those interested: the pip command depends on your environment (python version and operating system) and it is not the same for Linux, Mac, or Windows. Check the right boxes for your OS and choose “None” in the CUDA part on this website. It will give you the right installation command (you do not need vision and audio so you can remove that from the command).pytorch.orgPyTorchAn open source machine learning framework that accelerates the path from research prototyping to production deployment.
2020-12-13T10:42:47Z
Thanks. I installed conda and entered:conda install pytorch-cpu -c pytorch$ conda install pytorch-cpu -c pytorchCollecting package metadata (current_repodata.json): doneSolving environment: failed with initial frozen solve. Retrying with flexible solve.Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.Collecting package metadata (repodata.json): doneSolving environment: failed with initial frozen solve. Retrying with flexible solve.Solving environment: |Found conflicts! Looking for incompatible packages.This can take several minutes.  Press CTRL-C to abort.failedUnsatisfiableError: The following specifications were foundto be incompatible with the existing python installation in your environment:Specifications:pytorch-cpu → python[version=‘>=2.7,<2.8.0a0|>=3.7,<3.8.0a0|>=3.5,<3.6.0a0|>=3.6,<3.7.0a0’]This command fails with:Your python: python=3.8If python is on the left-most side of the chain, that’s the version you’ve asked for.When python appears to the right, that indicates that the thing on the left is somehownot available for the python version you are constrained to. Note that conda will notchange your python version to a different minor version unless you explicitly specifythat.So know I need to figure out how to downgrade my Python install with env or whatever.
2020-12-13T11:01:32Z
Installed Python 3.6 also (using an external apt-repository) and configured it to use those paths:sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python3.6export PYTHONPATH=/usr/bin/python3.6alias python=python3.6$ python --versionPython 3.6.12However conda still uses the latest Python version on my system. Don’t yet know where that is configured. The conda install still fails and prints: “Your python: python=3.8”
2020-12-13T11:03:32Z
Anyone has good ideas how to match the required Python version better on Ubuntu 20.04 LTS?
2020-12-15T01:19:36Z
I think you’re leaving off the last part - to install torch you need to select the correct config fromStart Locally | PyTorchand then run the command it tells you i.e,pip install torch==1.7.1+cpu -fhttps://download.pytorch.org/whl/torch_stable.htmlThe last argument is important as it tells pip where the wheels areI would also recomend usingpyenvandpyenv-virtualenv, it’ll allow you to install whatever version of python you want and create isolated environments - seeGitHub - pyenv/pyenv-installer: This tool is used to install `pyenv` and friends.
2020-12-15T15:09:36Z
Thanks, I got it running now without GPU complaints!Although the code is not producing output yet:from transformers import pipelineclassifier = pipeline(“zero-shot-classification”, model=‘joeddav/xlm-roberta-large-xnli’)sequence = “За кого вы голосуете в 2020 году?”candidate_labels = [“Europe”, “public health”, “politics”]classifier(sequence, candidate_labels)output:Some weights of the model checkpoint at joeddav/xlm-roberta-large-xnli were not used when initializing XLMRobertaForSequenceClassification: [‘roberta.pooler.dense.weight’, ‘roberta.pooler.dense.bias’]This IS expected if you are initializing XLMRobertaForSequenceClassification from the checkpoint of a model trained on another task or with another architecture (e.g. initializing a BertForSequenceClassification model from a BertForPreTraining model).This IS NOT expected if you are initializing XLMRobertaForSequenceClassification from the checkpoint of a model that you expect to be exactly identical (initializing a BertForSequenceClassification model from a BertForSequenceClassification model).Perhaps I am doing somthing wrong here, I will dig some more later.
2020-12-15T20:52:59Z
I’ve not quite got to that stage yet but I think it’s normal? My understanding is you pre train say XLMRobertaForMaskedLM which creates a model consisting of an encoder with an MLM head and no pooling layer. Once that’s trained you load it as a XLMRobertaForSequenceClassification which copies the trained encoder and adds pooling and a sequence classifier - you then need to fine-tune this?