深度学习踩坑记录(持续更新)

目录

  • 4060显卡cuda版本异常
  • [transformers 初始化 TrainingArguments 时 output_dir 指定问题](#transformers 初始化 TrainingArguments 时 output_dir 指定问题)

4060显卡cuda版本异常

环境:torch1.11.0+cu113

程序报错

复制代码
RuntimeError: nvrtc: error: invalid value for --gpu-architecture (-arch)

可能原因与解决办法

  1. 4060显卡是sm_89架构,支持11.7以上cuda,低版本cuda有异常

    运行以下代码可查看当前torch版本支持的gpu的架构,和当前gpu的架构

    python 复制代码
    import torch
    
    print(torch.cuda.get_arch_list())  # 返回['sm_37', 'sm_50', 'sm_60', 'sm_61', 'sm_70', 'sm_75', 'sm_80', 'sm_86', 'compute_37']
    print(torch.cuda.get_device_capability(0))  # 返回(8, 9),代表sm_89

    查看返回结果可知,当前torch版本不支持sm_89,可更新torch版本,运行以下代码安装

    复制代码
     pip install torch==1.13.1+cu117 torchvision==0.14.1+cu117 torchaudio==0.13.1 --extra-index-url https://download.pytorch.org/whl/cu117
  2. 程序打断点可以找到报错程序是一个带有 @torch.jit.script 装饰器的函数

    torch.jit.script 是将模型转换为脚本的函数。它接受一个 PyTorch 模型作为输入,并将其转换为可运行的脚本。转换后的脚本可以像普通的 Python 函数一样调用,也可以保存到磁盘并在没有 PyTorch 依赖的环境中执行。

    主要作用是降低解释器消耗,如果不要求性能,可以将装饰器注释掉,即可顺利运行。

transformers 初始化 TrainingArguments 时 output_dir 指定问题

环境:transformers=4.27.1

程序报错

复制代码
main.py: error: the following arguments are required: --output_dir

可能原因与解决办法

  1. 运行时未指定 output_dir 参数

    解决办法1:使用命令行运行程序 python main.py --output_dir ./output

    解决办法2:若使用pycharm 运行,可右键选择 Modify Run Configuration ,设置运行脚本参数--output_dir ./output

    解决办法3:继承TrainingArguments重新初始化output_dir,同时也可以初始化其他超参数

    python 复制代码
    from transformers import TrainingArguments
    
    @dataclass
    class MyTrainingArguments(TrainingArguments):
        max_steps: int = field(default=5000)
        save_steps: int = field(default=100)
        learning_rate: float = field(default=5e-5)
        logging_steps: int = field(default=10)
        output_dir: str = field(default='output')
        per_device_train_batch_size: int = field(default=1)
        gradient_accumulation_steps: int = field(default=8)
        do_train: bool = field(default=True)
    
    training_args = HfArgumentParser(MyTrainingArguments).parse_args_into_dataclasses()[0]
相关推荐
岁月的眸9 分钟前
【科大讯飞声纹识别和语音内容识别的实时接口实现】
人工智能·go·语音识别
Nautiluss12 分钟前
一起玩XVF3800麦克风阵列(十)
linux·人工智能·python·音频·语音识别·实时音视频·dsp开发
暴风鱼划水29 分钟前
大型语言模型(入门篇)B
人工智能·语言模型·大模型·llm
鼎道开发者联盟29 分钟前
构建活的界面:AIGUI底板的动态布局
人工智能·ui·ai·aigc·gui
无代码专家37 分钟前
设备巡检数字化闭环解决方案:从预防到优化的全流程赋能
大数据·人工智能
兔子小灰灰1 小时前
jetson安装pytorch
人工智能·pytorch·python
weilaikeqi11111 小时前
拙诚育泽携手澳仕玛,夯实青少年AI科技竞争力
人工智能·科技
卷心菜加农炮1 小时前
MPK(Mirage Persistent Kernel)源码笔记(3)--- 系统接口
人工智能
神算大模型APi--天枢6461 小时前
合规与高效兼得:国产全栈架构赋能行业大模型定制,从教育到工业的轻量化落地
大数据·前端·人工智能·架构·硬件架构