Coder Social home page Coder Social logo

Comments (12)

airaria avatar airaria commented on August 25, 2024

notebook里没处理好HF datasets数据格式。

修改train_dataloader附近的代码:

from torch.utils.data import DataLoader, RandomSampler
train_dataset=tokenized_datasets["train"].remove_columns(["id", "tokens","ner_tags"])
data_collator = DataCollatorForTokenClassification(tokenizer)
train_dataloader = DataLoader(train_dataset, sampler=RandomSampler(train_dataset), batch_size=32,collate_fn=data_collator)

将with_distiller改为:

def batch_postprocessor(batch):
  return dict(batch)
with distiller:
    distiller.train(optimizer, train_dataloader, num_epochs, scheduler_class=scheduler_class, scheduler_args = scheduler_args, callback=None,batch_postprocessor=batch_postprocessor)

from textbrewer.

MrRace avatar MrRace commented on August 25, 2024

@airaria 感谢,实测正常运行。但是在最后对蒸馏后的模型进行评测的时候trainer.evaluate(),这个cell的执行时候会报OutOfMemoryError: CUDA out of memory。经过测试发现,每个batch运行完之后,trainer 并不会释放前一个batch的显存,一直累积,导致显存一直没有释放,最终 OutOfMemoryError: CUDA out of memory。请问有办法通过设置的方式解决这个问题吗?谢谢~

image

from textbrewer.

stale avatar stale commented on August 25, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

from textbrewer.

stale avatar stale commented on August 25, 2024

Closing the issue, since no updates observed. Feel free to re-open if you need any further assistance.

from textbrewer.

jinxiaolinlin avatar jinxiaolinlin commented on August 25, 2024

您好,我在最后的trainer.evaluate()环节遇到了和您同样的问题,请问您最后是怎么解决的,十分感谢!

from textbrewer.

MrRace avatar MrRace commented on August 25, 2024

您好,我在最后的trainer.evaluate()环节遇到了和您同样的问题,请问您最后是怎么解决的,十分感谢!

官方没有回复,所以,我也是没有解决,弃用了

from textbrewer.

MrRace avatar MrRace commented on August 25, 2024

@airaria 有其他人也遇到这个问题,求助~

from textbrewer.

airaria avatar airaria commented on August 25, 2024

@airaria 有其他人也遇到这个问题,求助~

trainer.evaluate()之后就是transformer的脚本了,我这里没法控制。
你们的transformers版本号是多少?
我再看看notebook,不保证可以解决。

from textbrewer.

MrRace avatar MrRace commented on August 25, 2024

@airaria 有其他人也遇到这个问题,求助~

trainer.evaluate()之后就是transformer的脚本了,我这里没法控制。 你们的transformers版本号是多少? 我再看看notebook,不保证可以解决。

我怀疑是eval过程显存没有释放,一直累积,我这边的显存是40GB的

from textbrewer.

MrRace avatar MrRace commented on August 25, 2024

@airaria transformers Version =4.25.1,Thanks a lot!

from textbrewer.

airaria avatar airaria commented on August 25, 2024

@MrRace 建议参考py脚本: https://github.com/airaria/TextBrewer/tree/master/examples/msra_ner_example
ipynb因为依赖了较多datasets的特性,而且没更新,可能会有兼容性问题

from textbrewer.

MrRace avatar MrRace commented on August 25, 2024

@MrRace 建议参考py脚本: https://github.com/airaria/TextBrewer/tree/master/examples/msra_ner_example ipynb因为依赖了较多datasets的特性,而且没更新,可能会有兼容性问题

@airaria 这个范例,也是存在各种异常错误。求重跑一次,修复下。比如在蒸馏阶段,不支持student模型的随机初始化,而文档里面声称支持。

from textbrewer.

Related Issues (20)

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.