Skip to content

Transformer pipelines erroneously invokes torch #37680

@rishic3

Description

@rishic3

System Info

As originally pointed out by @radoslav-dimitrov-indeavr (see this comment), PR #37307 adds a torch invocation to pipelines, which will cause pure tensorflow applications to break.

transformers/src/transformers/pipelines/base.py:

        if torch.distributed.is_initialized():

Source

Who can help?

@ArthurZucker

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

Repro: create an environment with transformers and tensorflow but without pytorch.

classifier = pipeline("sentiment-analysis"

Output:

NameError: name 'torch' is not defined

Expected behavior

Given that pipelines are supported for pure Tensorflow applications, said applications should not require a pytorch installation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions