Comments (6)
What's your current error message?
from dnabert_2.
no obvious error, just the following, so I asked GPT.
AssertionError Traceback (most recent call last)
Cell In[4], line 3
1 dna = "ACGTAGCATCGGATCTATCTATCGACACTTGGTTATCGATCTACGAGCATCTCGTTAGC"
2 inputs = tokenizer(dna, return_tensors = 'pt')["input_ids"]
----> 3 hidden_states = model(inputs)[0] # [1, sequence_length, 768]
5 # embedding with mean pooling
6 embedding_mean = torch.mean(hidden_states[0], dim=0)
File ~/.conda/envs/dnat/lib/python3.8/site-packages/torch/nn/modules/module.py:1511, in Module._wrapped_call_impl(self, *args, **kwargs)
1509 return self._compiled_call_impl(*args, **kwargs) # type: ignore[misc]
1510 else:
-> 1511 return self._call_impl(*args, **kwargs)
.......
File ~/.cache/huggingface/modules/transformers_modules/DNABERT-2-117M/flash_attn_triton.py:1021, in _FlashAttnQKVPackedFunc.forward(ctx, qkv, bias, causal, softmax_scale)
1019 if qkv.stride(-1) != 1:
1020 qkv = qkv.contiguous()
-> 1021 o, lse, ctx.softmax_scale = _flash_attn_forward(
1022 qkv[:, :, 0],
1023 qkv[:, :, 1],
1024 qkv[:, :, 2],
1025 bias=bias,
1026 causal=causal,
1027 softmax_scale=softmax_scale)
1028 ctx.save_for_backward(qkv, o, lse, bias)
1029 ctx.causal = causal
File ~/.cache/huggingface/modules/transformers_modules/DNABERT-2-117M/flash_attn_triton.py:781, in _flash_attn_forward(q, k, v, bias, causal, softmax_scale)
778 assert q.dtype == k.dtype == v.dtype, 'All tensors must have the same type'
779 assert q.dtype in [torch.float16,
780 torch.bfloat16], 'Only support fp16 and bf16'
--> 781 assert q.is_cuda and k.is_cuda and v.is_cuda
782 softmax_scale = softmax_scale or 1.0 / math.sqrt(d)
784 has_bias = bias is not None
And GPT tell me :
It looks like the error is occurring within a custom implementation of attention mechanism (_FlashAttnQKVPackedFunc.forward). The assertion error is raised because the tensors q, k, and v are expected to be on a CUDA device (GPU), but the check assert q.is_cuda and k.is_cuda and v.is_cuda fails.
To resolve this issue, make sure that the tensors involved in the attention mechanism are on the same device. You can achieve this by explicitly moving the tensors to the GPU using the .to(device) method.
so I print the device:
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
output: false
So I think I should uninstall torch to cuda these:
pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 cudatoolkit=11.3 -c pytorch (my Cuda is 11.4)
from dnabert_2.
Please try "pip uninstall triton".
from dnabert_2.
Yes, I create a new environment,and I do not pip triton.
from dnabert_2.
It automatically install triton so you need to manually remove it.
from dnabert_2.
YES, you are right!!!! Thank you so much ~~~~~
from dnabert_2.
Related Issues (20)
- When will the pretraining code be available?
- .
- environment about torch version HOT 1
- hidden_states = model(inputs)[0] # [1, sequence_length, 768]-- Is the second dimension really the sequence length? HOT 1
- Discuss a question about k-mer HOT 1
- When will the code for pre-training model and training BPE tokenizer be available? HOT 1
- Quickstart Does not work and Embedding Dim is not 768 HOT 1
- Pretraining, Pretraining, Pretraining!!! HOT 2
- I always encounter this error during the fine-tuning evaluation phase HOT 1
- Fine-tune for continuous labels HOT 3
- How do I output the attention from the model? HOT 1
- Special token treatment. HOT 1
- splice site predictions
- Unable to Retrieve ' hidden_states ' Despite ' Setting return_dict=True ' and ' output_hidden_states=True ' HOT 3
- Cannot Reproduce DNA-BERT2‘s Result HOT 1
- GUE+ datasets? HOT 2
- Is it neccessary to train a specific BPE tokenizer on own datasets? HOT 1
- Getting embedding of a sequence HOT 2
- CUDA out of memory HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dnabert_2.