记困扰很久的pytorch加载模型OOM,python import执行流程,python“懒运行”,whindows控制ubuntu远程桌面

本文探讨了PyTorch加载模型时遇到的内存溢出问题,以及Python的import执行流程。强调了在import时避免耗内存的初始化操作,并提供了解决方案。同时,文章还介绍了Windows远程控制Ubuntu桌面的方法。

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

前言

半路接手项目,阅读代码,解决bug,优化速度。

part one

  1. 1050 Ti加载模型时OOM
    model.load_state_dict(torch.load(path))

Copies parameters and buffers from :attr:state_dict into
this module and its descendants. If :attr:strict is True, then
the keys of :attr:state_dict must exactly match the keys returned
by this module’s :meth:~torch.nn.Module.state_dict function.
Arguments:
state_dict (dict): a dict containing parameters and
persistent buffers.
strict (bool, optional): whether to strictly enforce that the keys
in :attr:state_dict match the keys returned by this module’s
:meth:~torch.nn.Module.state_dict function. Default: True
2019/1/16补:
其实问题是出在main函数,当时一直没考虑到(因为Java中必须得主函数作为运行入口,Python不强求,所以写Python代码没养成好习惯)。
所以,尽量写

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值