一些意外的bug

类型一:安装包问题

1、包内部代码报错,如:某方法没有

检查版本:

python -> import 包名 -> 包名.version -> 包名.file

若import 的包名与 pip安装的包的路径不一致,则copy过去

具体:

1、key llama error transformers问题,需安装4.28

2、deepspeed没有adam_cuda属性,需要安装0.8.3 (torch的版本要1.12.1的)

类型二:目录没有权限

sudo chmod 777 dir

sudo chmod 777 dir/* (目录下的文件负最大权限)

类型三、python使用版本不对

sudo python与python用的不是同一个python

解决办法:

iii. sudo cp /usr/bin/python /usr/bin/python_bak

iv. sudo rm /usr/bin/python

v. sudo ln -s /opt/conda/bin/python /usr/bin/python

类型三、cpu与gpu上的半精度问题

def normalize(x, axis=-1):

x = 1. * x / (torch.norm(x, 2, axis, keepdim=True).expand_as(x)+1e-12)

return x

embed 目前在显卡上且是半精度

normalize(embed_f).cpu() 与 normalize(embed_f.cpu()) 的结果会不一样,后者会改变精度

解决办法:采用normalize(embed_f.cpu().float())

tips:这三种结果都有细微 的差别,只是normalize(embed_f.cpu())差别很明显

numpy与tensor 取值问题:

复制代码
[str(i.item()) for i in normalize(embed_f[0]).cpu().numpy()]

result:['0.02435302734375', '0.0052337646484375']

[str(i) for i in normalize(embed_f[0]).cpu().numpy()]

result:['0.02435', '0.005234']

cuda error:

RuntimeError: CUDA error: device-side assert triggered

CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.

For debugging consider passing CUDA_LAUNCH_BLOCKING=1.

Compile with `TORCH_USE_CUDA_DSA` to enable device-side assertions.

解决办法:python 前面加入CUDA_VISIBLE_DEVICES=3

llama1 加入这一串也能解决:

复制代码
if tokenizer.pad_token is None:
        DEFAULT_PAD_TOKEN = "[PAD]"
        DEFAULT_EOS_TOKEN = "</s>"
        DEFAULT_BOS_TOKEN = "</s>"
        DEFAULT_UNK_TOKEN = "</s>"
        tokenizer.add_special_tokens(
            {
                "eos_token": DEFAULT_EOS_TOKEN,
                "bos_token": DEFAULT_BOS_TOKEN,
                "unk_token": DEFAULT_UNK_TOKEN,
                "pad_token": DEFAULT_PAD_TOKEN,
            }
        )
        tokenizer.add_eos_token = False
相关推荐
万粉变现经纪人2 小时前
如何解决 pip install 编译报错 ‘cl.exe’ not found(缺少 VS C++ 工具集)问题
开发语言·c++·人工智能·python·pycharm·bug·pip
月小满1 天前
DataV轮播时其他组件的内容也一起滚动 修复bug的方法
前端·vue.js·bug·大屏端
桃子丫1 天前
AD转 Cadence学习指南-BUG篇
bug
testtraveler1 天前
[Fix] ImportError: libtorch_cpu.so: undefined symbol: iJIT_NotifyEvent
pytorch·python·bug
测试者家园1 天前
从“找 bug”到“降风险”:测试思维模式的底层迁移
软件测试·bug·风险管理·持续测试·测试基础·智能化测试·测试思维模式
chde2Wang2 天前
运行scala文件报错xsbt.CompilerInterface
bug·scala
离离茶3 天前
【笔记1-8】Qt bug记录:QListWidget窗口的浏览模式切换为ListMode后,滚轮滚动速度变慢
笔记·qt·bug
程序猿阿伟3 天前
《从被动修复到免疫:游戏Bug闭环体系的深度搭建指南》
游戏·bug
Cola可洛6 天前
修复Flyme移植BUG
android·bug
Bear on Toilet6 天前
C++_Bug:现代写法拷贝构造中 swap 写法之小坑
数据结构·c++·bug