Sunil Surendra Singh
Sunil Surendra Singh

Reputation: 51

Huggingface Transformers Conda Install issue

conda by default installing transformers 2.x however pip installs 4.x by default which is what I want but via conda.

If I install by specifying the latest distribution file from conda-forge… conda install https://anaconda.org/conda-forge/transformers/4.16.2/download/noarch/transformers-4.16.2-pyhd8ed1ab_0.tar.bz2

then it complains that environment is not consistent and list the package causing the issue which is PyTorch version 1.11.

I removed pytorch and then installed as listed above then installation go through. I then tried installing datasets… conda install datasets

Now it complains that environment is inconsistent due to transformers 4.16.2 that I installed.

Not sure whats wrong and how to install pytorch, transformers and datasets together with no issue. Do I need specific versions of these to make it work, could not find any such guideline on huggingface docs or support pages.

thanks.

Upvotes: 5

Views: 12570

Answers (2)

altamont
altamont

Reputation: 463

What worked for me is to download from conda-forge channel instead of huggingface channel, i.e. conda install conda-forge::transformers

Upvotes: 0

Gonçalo Peres
Gonçalo Peres

Reputation: 13582

Just tried installing transformers in the venv that I will be working on as follows

conda install transformers

And it installed the version transformers-4.18.0.

If one wants to install specifically from the channel huggingface, then do the following

conda install -c huggingface transformers

Last case scenario, install it with pip, as using pip can potentially wreck one's installation (pip and conda do not manage dependencies in the same way).

pip install transformers

Or, by specifying the version

pip install transformers==4.18.0

Or directly from the source

pip install git+https://github.com/huggingface/transformers

If one has transformers already installed and wants to install a different version than the one we currently have, one should pass -Iv (as suggested here)

pip install -Iv transformers==4.18.0 

To check if transformers was properly installed, run the following

python -c "from transformers import pipeline; print(pipeline('sentiment-analysis')('we love you'))"

It will download a pretrained model, then print out the label and score.


For more information on transformers installation, consult this page.

Upvotes: 8

Related Questions