Git Product home page Git Product logo

Comments (5)

xuelicheng1992 avatar xuelicheng1992 commented on May 28, 2024

new_tokens=["443"]
model = "bert-base-chinese"
tokenizer = BertTokenizer.from_pretrained(model, use_fast=True)
model = BertForMaskedLM.from_pretrained(model)
num_added_toks = tokenizer.add_tokens(new_tokens)
model.resize_token_embeddings(len(tokenizer))
tokenizer.save_pretrained("bert-base-chinese")
执行上述代码回在模型下面生成 added_tokens.json文件。
训练时tcData.py文件
将tokenizer = PretrainedTokenizer.from_pretrained(config.pretrained_model_name_or_path)替换为
from transformers import BertTokenizer
tokenizer = BertTokenizer.from_pretrained(config.pretrained_model_name_or_path)
或者手动添加方法
开始训练模型时都会报错。

from pytorch-nlu.

xuelicheng1992 avatar xuelicheng1992 commented on May 28, 2024

Traceback (most recent call last):
File "/home/pacs/PycharmProjects/untitled/myT/Pytorch-NLU_test.py", line 74, in
lc.train()
File "/home/pacs/miniconda3/envs/py39/lib/python3.9/site-packages/pytorch_nlu/pytorch_textclassification/tcRun.py", line 97, in train
self.office.train_model()
File "/home/pacs/miniconda3/envs/py39/lib/python3.9/site-packages/pytorch_nlu/pytorch_textclassification/tcOffice.py", line 215, in train_model
outputs = self.model(**inputs)
File "/home/pacs/miniconda3/envs/py39/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/home/pacs/miniconda3/envs/py39/lib/python3.9/site-packages/pytorch_nlu/pytorch_textclassification/tcGraph.py", line 63, in forward
output = self.model(input_ids, attention_mask=attention_mask, token_type_ids=token_type_ids)
File "/home/pacs/miniconda3/envs/py39/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/home/pacs/miniconda3/envs/py39/lib/python3.9/site-packages/transformers/models/bert/modeling_bert.py", line 1020, in forward
encoder_outputs = self.encoder(
File "/home/pacs/miniconda3/envs/py39/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/home/pacs/miniconda3/envs/py39/lib/python3.9/site-packages/transformers/models/bert/modeling_bert.py", line 610, in forward
layer_outputs = layer_module(
File "/home/pacs/miniconda3/envs/py39/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/home/pacs/miniconda3/envs/py39/lib/python3.9/site-packages/transformers/models/bert/modeling_bert.py", line 495, in forward
self_attention_outputs = self.attention(
File "/home/pacs/miniconda3/envs/py39/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/home/pacs/miniconda3/envs/py39/lib/python3.9/site-packages/transformers/models/bert/modeling_bert.py", line 425, in forward
self_outputs = self.self(
File "/home/pacs/miniconda3/envs/py39/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/home/pacs/miniconda3/envs/py39/lib/python3.9/site-packages/transformers/models/bert/modeling_bert.py", line 284, in forward
mixed_query_layer = self.query(hidden_states)
File "/home/pacs/miniconda3/envs/py39/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/home/pacs/miniconda3/envs/py39/lib/python3.9/site-packages/torch/nn/modules/linear.py", line 114, in forward
return F.linear(input, self.weight, self.bias)
RuntimeError: CUDA error: CUBLAS_STATUS_NOT_INITIALIZED when calling cublasCreate(handle)

from pytorch-nlu.

yongzhuo avatar yongzhuo commented on May 28, 2024

复现但是没有出错呢,你这报错看着像是cuda的问题,比如版本不兼容pytorch
image
image

from pytorch-nlu.

xuelicheng1992 avatar xuelicheng1992 commented on May 28, 2024

找到原因了,我用pip install -i https://pypi.tuna.tsinghua.edu.cn/simple Pytorch-NLU 安装的导致不是最新版代码。

from pytorch-nlu.

xuelicheng1992 avatar xuelicheng1992 commented on May 28, 2024

大佬,谢谢了帮忙排查问题。

from pytorch-nlu.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.