Search code examples
pytorch

How does one install torchtext with cuda >=11.0 (and pytorch 1.9)?


I've tried multiple things e.g.

conda install -y pytorch==1.9 torchvision torchaudio torchtext cudatoolkit=11.0 -c pytorch -c nvidia

but it never ends up downloading the version with cuda 11.0 or above for some reason.

The error message is too large to paste but you can see details here: https://github.com/pytorch/text/issues/1395

It should be easy to reproduce with an empty env as follow:

conda create -n env_a40 python=3.9
conda activate env_a40
conda install -y pytorch==1.9 torchvision torchaudio torchtext cudatoolkit=11.0 -c pytorch -c nvidia

crossposted:

related:


note you can also try it with pip:

pip3 install torch==1.9.0+cu111 torchvision==0.10.0+cu111 torchaudio==0.9.0 -f https://download.pytorch.org/whl/torch_stable.html

with no success yet.


Solution

  • For me it worked with torchtext 0.10.1. The order of how I did things is install pytorch first with:

    pip3 install torch==1.9.1+cu111 torchvision==0.10.1+cu111 torchaudio==0.9.1 -f https://download.pytorch.org/whl/torch_stable.html
    

    (probably use the most recent command from the pytorch website https://pytorch.org/get-started/locally/, but if that doesn't work then go to the torchtext website to see what versions of python and pytorch they support and install that. Hopefully in the future torchtext will be in line with the main pytorch branch https://github.com/pytorch/text)

    Then since I was using my personal library I installe it in editable mode:

    pip install -e ~/ultimate-utils/ultimate-utils-proj-src
    

    or from pypi

    pip install ultimate-utils
    

    then go to python to test the pytorch version:

    (uutils_env) miranda9~/type-parametric-synthesis $ python
    Python 3.9.7 (default, Sep 16 2021, 13:09:58) 
    [GCC 7.5.0] :: Anaconda, Inc. on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import torchtext
    
    >>> 
    >>> from torchtext.vocab import Vocab
    >>> 
    

    it knows to install the right version due to my setup.py file. But you can install the right version as follows:

    pip install torchtext==0.10.1
    

    In the future the above versions might change and you might have to open an issue in torchtext's github.

    Note:

    If you are using pip do:

    pip3 install torch==1.9.1+cu111 torchvision==0.10.1+cu111 torchaudio==0.9.1 -f https://download.pytorch.org/whl/torch_stable.html
    pip3 install torchtext==0.10.1
    

    probably can be compressed to:

    pip3 install torch==1.9.1+cu111 torchvision==0.10.1+cu111 torchaudio==0.9.1 torchtext==0.10.1 -f https://download.pytorch.org/whl/torch_stable.html
    

    but have not tried it.

    Acks: In particular thanks @ivan for the help!