pytorch开发经验问题总结-更新ing

本文介绍了在使用PyTorch时遇到的Caffe2线程池泄露警告及其解决方法,涉及数据加载器参数num_workers的调整。此外,还讨论了PyTorch模型中模块属性错误的问题,指出这可能是由于版本不匹配导致,并提供了解决方案。同时,解释了torch.cuda.synchronize()的作用,确保GPU计算完成后再进行时间测量。最后,提到了@torch.no_grad()修饰符在评估模型时的使用,以及如何在训练过程中调整学习率以优化模型性能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

问题一:

[W pthreadpool-cpp.cc:90] Warning: Leaking Caffe2 thread-pool after fork. (function pthreadpool)
[W pthreadpool-cpp.cc:90] Warning: Leaking Caffe2 thread-pool after fork. (function pthreadpool)
[W pthreadpool-cpp.cc:90] Warning: Leaking Caffe2 thread-pool after fork. (function pthreadpool)
[W pthreadpool-cpp.cc:90] Warning: Leaking Caffe2 thread-pool after fork. (function pthreadpool)

parser.add_argument(’–num_workers’,default=1,type=int)

https://discuss.pytorch.org/t/dataloader-when-num-worker-0-there-is-bug/25643/37

问题二:

    raise ModuleAttributeError("'{}' object has no attribute '{}'".format(
torch.nn.modules.module.ModuleAttributeError: 'AnchorGenerator' object has no attribute '_cache'

原因是pytorch版本问题,训练模型和测试的版本不一致

问题三:

torch.cuda.synchronize()
model_time = time.time()

使用该操作等待GPU全部执行结束,再执行model_time = time.time()

问题四:
@torch.no_grad()
def evaluate(model, data_loader, device):

修饰符

问题五:
调整学习率
在这里插入图片描述

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值