question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

from_dlpack in spacy-transformers

See original GitHub issue

The test suite for spacy-transformers breaks in my local environment since PR https://github.com/explosion/thinc/pull/686

numpy                             1.23.1
spacy                             3.4.1        (current master)
spacy-transformers                1.1.2        (current master)
thinc                             8.1.0        (current master)
torch                             1.9.0+cu111

e.g. when I run test_model_sequence_classification, it crashes at https://github.com/explosion/thinc/blob/master/thinc/util.py#L365:

>           torch_tensor = torch.utils.dlpack.from_dlpack(xp_tensor)
E           RuntimeError: from_dlpack received an invalid capsule. Note that DLTensor capsules can be consumed only once, so you might have already constructed a tensor from it once.

But, when I look at the code behind from_dlpack and run this directly (having confirmed my system doesn’t hit the if statement checking the device):

dlpack = xp_tensor.__dlpack__()
torch_tensor = torch._C._from_dlpack(dlpack)

Then the test flies through.

Can anyone reproduce the failing tests on the spacy-transformers test suite with a relatively new numpy?

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
polmcommented, Aug 10, 2022

This also came up in the coref PR in spacy-experimental. It was pretty confusing but upgrading the Torch version did fix it.

0reactions
svlandegcommented, Aug 16, 2022

Ok, good points. Let’s close this and leave as-is for now. If we do get external reports, we can consider adding a warning.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AttributeError: module 'torch.utils' has no attribute 'dlpack ...
Sounds like this might be an issue with your torch install. Could you post the output of pip freeze ? How did you...
Read more >
Transformer · spaCy API Documentation
This pipeline component lets you use transformer models in your pipeline. It supports all models that are available via the HuggingFace transformers library....
Read more >
spacy-transformers · spaCy Universe
This package provides spaCy model pipelines that wrap Hugging Face's transformers package, so you can use them in spaCy. The result is convenient...
Read more >
Model Architectures · spaCy API Documentation
This page documents spaCy's built-in architectures that are used for ... Load and wrap a transformer model from the HuggingFace transformers library.
Read more >
Embeddings, Transformers and Transfer Learning - spaCy
spaCy lets you share a single transformer or other token-to-vector (“tok2vec”) embedding layer between multiple components. You can even update the shared layer ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found