from_dlpack in spacy-transformers
See original GitHub issueThe 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:
- Created a year ago
- Reactions:1
- Comments:10 (10 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This also came up in the coref PR in
spacy-experimental
. It was pretty confusing but upgrading the Torch version did fix it.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.