Farm: Problems when installing FARM : ERROR: Could not find a version that satisfies the requirement torch==1.5.*

Created on 5 Aug 2020  路  13Comments  路  Source: deepset-ai/FARM

Hi,
I was working with FARM in Google Colab do create a deep learning model for text classification. I've saved the model using the model.save and processor.save and then testet it with loading the model with the Inferencer, which worked all perfectly fine.
Now i was trying to deploy the model and integrate it to a flask script to later load it into a webapp.
I am using pycharm for this but I am having troubles loading and installing FARM. Up to now, I've tried all kinds of different versions to install Farm such as

  • installing it in pycharm with a requirements.txt file
  • installing it from the pycharm terminal using pip install farm, pip install farm==0.4.6, or cloning the GIT Repo, call requirements.txt and --editable .
  • installing it from the package "store" in pycharm

nothing fully worked. Sometimes it seemed to have installed FARM, but when i tried to import farm (or from farm.infer import Inferencer), I kept getting a Win126 error (specific module not found) and after googling I' came across this issue with updating torch but cudaonly, so I did that but it didn't solve the problem. I also tried to delete and deinstall everything and start fresh, but I am still getting "module not found" erros or it evens kills installing and I cant even properly install FARM anymore.
So I thought that this might be because of my windows machine or some updates I did, so I tried ubuntu(version 20.04) in my VM, and when trying to install FARM from pycharm in Ubuntu system, its not working either., giving me a "non-zero exit code (137)" error.
I've also tried another laptop, started pycharm, created a requirements.txt file and wanted to install farm.
Again, i got the error.

ERROR: Could not find a version that satisfies the requirement torch==1.5.* (from farm) (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2)
Proposed Solution:
Try to run this command from the system terminal. Make sure that you use the correct version of 'pip' installed for your Python interpreter located at 'C:\Users\Coreyn\PycharmProjects\testElea\venv\Scripts\python.exe'.

Command Output:

Collecting farm
  Using cached farm-0.4.6-py3-none-any.whl (184 kB)
Requirement already satisfied: tqdm in c:\users\coreyn\pycharmprojects\testelea\venv\lib\site-packages (from farm) (4.48.2)
Collecting scipy>=1.3.2
  Using cached scipy-1.5.2-cp37-cp37m-win_amd64.whl (31.2 MB)
Collecting dill
  Using cached dill-0.3.2.zip (177 kB)
Collecting wheel
  Using cached wheel-0.34.2-py2.py3-none-any.whl (26 kB)
Collecting sklearn
  Downloading sklearn-0.0.tar.gz (1.1 kB)
Collecting flask-cors
  Downloading Flask_Cors-3.0.8-py2.py3-none-any.whl (14 kB)
Collecting seqeval
  Downloading seqeval-0.0.12.tar.gz (21 kB)
Collecting psutil
  Using cached psutil-5.7.2-cp37-cp37m-win_amd64.whl (242 kB)
Collecting Werkzeug==0.16.1
  Using cached Werkzeug-0.16.1-py2.py3-none-any.whl (327 kB)
Collecting flask-restplus
  Downloading flask_restplus-0.13.0-py2.py3-none-any.whl (2.5 MB)

DEPRECATION: The -b/--build/--build-dir/--build-directory option is deprecated. pip 20.3 will remove support for this functionality. A possible replacement is use the TMPDIR/TEMP/TMP environment variable, possibly combined with --no-clean. You can find discussion regarding this at https://github.com/pypa/pip/issues/8333.
ERROR: Could not find a version that satisfies the requirement torch==1.5.* (from farm) (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2)
ERROR: No matching distribution found for torch==1.5.* (from farm)

I tried what is stated in the propsed solution, but got (almost) the same error:

ERROR: Could not find a version that satisfies the requirement torch==1.5.* (from farm) (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2)
ERROR: No matching distribution found for torch==1.5.* (from farm)

That was my last try and I really don't know why I can't be able to install farm properly and import Inferencer, which I need to load my model and deploy it to a webapp. I am new to programming, but I guess it must be some technical issue with the torch==1.5 version, but clueless how to solve, since all my previous approaches have been failing.

So, you guys are my last help! :D
I am using python3.7, pip 20.2.1 and Windows10, 64bit OR ubuntu20.04 on my VM

Any help appreciated!

bug

Most helpful comment

@YojanaGadiya yes!! Now it works, thanks a lot!!
Tried with anaconda environment and used https://github.com/pytorch/pytorch/issues/37022 to solve the issues

All 13 comments

Seems similar to https://github.com/deepset-ai/haystack/issues/289
And I guess it is a windows issue in combination with the wildcard torch versioning.
Did you try setting in the requirements.txt the pytorch==1.5.1 (replacing the * with a 1)?

just did it now. (cloned the git repo, manually changed the req. file, ran the req file and ran --editable .)
could install farm succesfully, however, when I was importing the module (from farm.infer import Inferencer OR simply import farm), I got the following error message:


from farm.infer import Inferencer
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2020.2\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "c:\users\c_ruc\pycharmprojects\testelea\farm\farm\__init__.py", line 3, in <module>
    import torch.multiprocessing as mp
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2020.2\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "C:\Users\c_ruc\PycharmProjects\testElea\venv\lib\site-packages\torch\__init__.py", line 81, in <module>
    ctypes.CDLL(dll)
  File "C:\Users\c_ruc\AppData\Local\Programs\Python\Python37\lib\ctypes\__init__.py", line 364, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found

@tanaysoni could you please have a look since it seems like a highly windows specific issue. Thanks

Hi @Coooorinne, do you still face the issue? It seems like an issue with the PyTorch installation.

Could you test if import torch gets executed successfully?

This is because the PyTorch version 1.5.* does not support CUDA. You can try and install a specific version of PyTorch using !pip install torch==1.5.0+cu101 torchvision==0.6.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html

Hi @YojanaGadiya and @tanaysoni , thanks for the help!
I've tried installing the specific version of PyTorch using !pip install torch==1.5.0+cu101 torchvision==0.6.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html, which worked. I then cloned the Farm Git Repo and deletet the pytorch requirement in the requirements.txt file. and then installed farm. I got the message that farm was successfully installed.
But I can't import farm now.
I get the following error:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2020.2\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "c:\users\c_ruc\pycharmprojects\elea\farm\farm\__init__.py", line 3, in <module>
    import torch.multiprocessing as mp
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2020.2\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "C:\Users\c_ruc\AppData\Local\Programs\Python\Python37\lib\site-packages\torch\__init__.py", line 81, in <module>
    ctypes.CDLL(dll)
  File "C:\Users\c_ruc\AppData\Local\Programs\Python\Python37\lib\ctypes\__init__.py", line 364, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found

And ideas on that?

@Coooorinne why are you cloning the FARM repo? If you want to use that package, you can simply pip install it google colab.

@YojanaGadiya I need farm on my local machine not google colab so I am working on pycharm. but when simply install farm via pip install farm, I get the problem with the torch version (see error below). That's why i tried to clone the git repo and remove the wildcard form pytorch in the requirements.txt or do what you suggested with the specific version including CUDA. Like that the installation worked but I cannot import it.
Error:
ERROR: Could not find a version that satisfies the requirement torch==1.5.* (from farm) (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2)

@Coooorinne This is weird as I am also using Pycharm and I can work with both torch and farm by installing it in my environment using pip. Could you provide details about your device?

@Coooorinne Maybe you can try upgrading your python from 3.7 --> 3.8. Let me know if it works.

@YojanaGadiya thanks, i upgraded to 3.8. used the pycharm terminal, installed the specific version of pytorch in my venv and then installed farm in my venv with pip install farm. Installation seemed to have worked but when importing farm in the pycharm python console it throws this error:

>>>import farm
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\Users\c_ruc\AppData\Local\JetBrains\PyCharm Community Edition 2020.2\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "C:\Users\c_ruc\PycharmProjects\pythonProject\venv\lib\site-packages\farm\__init__.py", line 3, in <module>
    import torch.multiprocessing as mp
  File "C:\Users\c_ruc\AppData\Local\JetBrains\PyCharm Community Edition 2020.2\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "C:\Users\c_ruc\PycharmProjects\pythonProject\venv\lib\site-packages\torch\__init__.py", line 81, in <module>
    ctypes.CDLL(dll)
  File "C:\Users\c_ruc\AppData\Local\Programs\Python\Python38\lib\ctypes\__init__.py", line 369, in __init__
    self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'C:\Users\c_ruc\PycharmProjects\pythonProject\venv\lib\site-packages\torch\lib\caffe2_nvrtc.dll'. Try using the full path with constructor syntax.

I am using windows 10 home OS on my HP Spectre notebook.
Processor: Intel (R) COre (TM), i5-7200 CPU @ 2.5GHz, 2.71 GHz
System type: 64 bit operating system

@Coooorinne I used anaconda as my python interpreter. Hence I do not get such an error. I found this link. Hope it helps!

@YojanaGadiya yes!! Now it works, thanks a lot!!
Tried with anaconda environment and used https://github.com/pytorch/pytorch/issues/37022 to solve the issues

Was this page helpful?
0 / 5 - 0 ratings