- 博客(134)
- 收藏
- 关注
原创 ImportError: cannot import name ‘Qwen2VLForConditionalGeneration‘ from ‘transformers‘
4.44.2版本的 transformer 会有标题的错误。装完版本是 4.45.0.dev0。
2024-09-10 16:28:38 358
原创 慎用 np.vstack 和 np.hstack
连接2个array,如果是1维数组,要用 np.hstack,2维数组,要用 np.vstack。但可以统一用 np.concatenate(, axis=0)。
2024-06-21 17:06:13 207 1
原创 远程连接 vscode 出错 “远程主机可能不符合 glibc 和 libstdc++ VS Code 服务器的先决条件”
下载 1.85.2,https://update.code.visualstudio.com/1.85.2/win32-x64-archive/stable。vscode 版本是 1.86,服务器上的 glibc 和 libstdc++ 版本不满足。
2024-02-22 15:52:26 1617
原创 在 docker 中安装 sam
3、进入 segment-anything 目录,用 pip install . 安装。1、进入 docker,共享一个主机的目录。2、在主机的目录中做 git clone。
2023-12-15 14:51:12 629
原创 “RuntimeError: Unable to find a valid cuDNN algorithm to run convolution“
调小 batch size。
2023-10-26 10:27:01 110
原创 pytorch 的 dataset 中使用 onnxruntime
把 DataLoader 中 num_workers 设置成 0 就好了。
2022-12-13 19:11:11 1376 1
原创 timm 和 torchvision 中的 resnet50
从 timm 和 torchvision 分别加载 resnet50 预训练模型,从 onnx 看,权重是一样的。
2022-11-14 16:50:28 1632 1
原创 torch.autocast 放在 forward 中
使用 DDP时,如果不是 每块 GPU 一个进程,torch.autocast 应该放在 forward 中。
2022-10-09 15:55:13 581
原创 cross entropy loss = log softmax + nll loss
cross entropy loss = log softmax + nll loss
2022-06-07 16:58:43 376
原创 IndexError: shape mismatch: indexing tensors could not be broadcast together with shapes [2], [3]
import torcha = torch.randn(3,5)print(a)# 下行会有错误 IndexError: shape mismatch: indexing tensors could not be broadcast together with shapes [2], [3]#b = a[[0,2],[1,3,4]] # 改成 b = a[[0,2],:][:,[1,3,4]] print(b)输出是:tensor([[ 0.3627, -0.7073, -0.39.
2022-05-09 15:05:27 1753
原创 [8] Assertion failed: dims.nbDims == 4 || dims.nbDims == 5
onnx 转 trt 的时候出现错误:[04/22/2022-15:45:13] [W] [TRT] onnx2trt_utils.cpp:220: Your ONNX model has been generated with INT64 weights, while TensorRT does not natively support INT64. Attempting to cast down to INT32.[04/22/2022-15:45:13] [E] [TRT] (Unnamed
2022-04-22 16:18:55 1773
原创 enforce fail at inline_container.cc:222
执行 torch.load 时出现错误:“RuntimeError: [enforce fail at inline_container.cc:222] . file not found: archive/data/94479765723472”或者“RuntimeError: [enforce fail at inline_container.cc:145] . PytorchStreamReader failed reading file data/94100453134480: inval
2022-04-14 15:54:40 3642 3
原创 使用 trt 的int8 量化和推断 onnx 模型
目录生成 trt 模型1、使用代码2、onnx模型和图片3、修改代码4、结果推断 trt 模型生成 trt 模型1、使用代码https://github.com/rmccorm4/tensorrt-utils.git2、onnx模型和图片模型:动态batch输入(假设为mob_w160_h160.onnx,输入是 [batchsize, 3, 160, 160])。图片:一堆图片(假设有1024张),不需要其他描述文件。在tensorrt-u...
2022-03-27 22:55:41 8424 2
原创 画 ArcFace 中的 margin 曲线
效果如下:代码如下:from math import cos, sin, piimport numpy as npimport matplotlib.pyplot as plt'''# https://github.com/deepinsight/insightface/blob/master/recognition/arcface_torch/losses.pyclass ArcFace(torch.nn.Module): """ ArcFace (https:/..
2022-03-17 20:12:22 511
原创 Unable to determine the device handle for GPU 0000:02:00.0: GPU is lost.
TITAN X (Pascal) 的显卡,当 batch size 过大爆显存时,就会出现 GPU丢失 的错误。
2022-02-17 18:49:51 1113
原创 unhandled system error, NCCL version 2.7.8
在 宿主机上运行基于 DDP 的 pytorch 训练程序没问题,进入 docker 后运行,出现 "unhandled system error, NCCL version 2.7.8" 的错误。解决方法:在 python -m torch.distributed.launch --nproc_per_node=4 ...前加上 NCCL_DEBUG=INFO可以看到:s215:623:649 [3] include/shm.h:48 NCCL WARN Error while cr
2022-02-16 17:58:14 4805 1
原创 在两台 ubuntu 上安装 K8S
参考:1、ubuntu 安装 k8s2、报错:The connection to the server localhost:8080 was refused - did you specify the right host or port?3、Connecting to raw.githubusercontent.com failed: Connection refused. 解决办法安装 flannel 时使用:(python38) ai200@ubuntu16:/$ kubectl
2022-02-15 16:27:35 871
原创 在两台 ubuntu 之间传输大文件
方法1:scp -c aes128-gcm@openssh.coma.tar.gz usrname@ip:dir加上 -c aes128-gcm@openssh.com,可以加速。方法2:rsync -avP a.tar.gz usrname@ip:dir参考:1、linux中scp传文件速度慢原因2、为什么scp这么慢,如何使它更快?...
2022-01-25 10:38:36 1555
原创 ubuntu14.04 升级到 ubuntu16.04
参考:将Ubuntu 16.04 LTS 升级到 18.04 LTS | 以及问题汇总# 升级前(base) root@s215:~# cat /proc/versionLinux version 3.13.0-147-generic (buildd@lcy01-amd64-024) (gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.4) ) #196-Ubuntu SMP Wed May 2 15:51:34 UTC 2018# 升级后(bas
2022-01-24 16:21:20 1065
原创 多机多卡训练时的错误
错误1:“NCCL WARN Connect to failed : Network is unreachable”解决方法:设置环境变量NCCL_SOCKET_IFNAME=enp(有可能是eno,可以先用ifconfig 查看)
2021-12-23 19:51:50 1922 1
原创 onnxruntime-gpu 1.7 出现的警告“Force fallback to CPU execution for node: Gather_191”等
使用 onnxruntime-gpu(简称ORT)1.7 推断 onnx模型时出现如下警告,2021-12-01 15:50:30.792327215 [W:onnxruntime:Default, fallback_cpu_capability.cc:135 GetCpuPreferredNodes] Force fallback to CPU execution for node: Gather_1912021-12-01 15:50:30.792374122 [W:onnxruntime:De
2021-12-01 17:16:00 2293
原创 被 onnx.checker.check_model 检查出的常见错误
错误1:“Field 'name' of graph is required to be non-empty.”解决:对 model.graph.name 赋值。错误2:“Nodes in a graph must be topologically sorted, however input ...”解决:调整节点顺序,保证每个节点的输入都先于它存在。参考代码如下:def check_update_model(model): if (model.graph.name == ''
2021-11-10 17:51:08 5239 2
原创 rearrange 和 einsum 真的优雅吗
结论是,还好吧。从代码量看,差不多:# -*- coding:utf-8 -*-import torchfrom torch import nnfrom torch import einsumfrom einops import rearrangeclass SimpleQKV(nn.Module): def __init__(self, dim, use_ein): super().__init__() self.proj = nn.Linea
2021-11-09 10:59:19 746
原创 swin transformer 转 onnx
swin transformer 代码非官方实现,但是好理解。转 onnx 代码:import torchfrom swin_transformer_pytorch import swin_tpth_filename = './demo.pth' # 训练好的权重onnx_filename = './demo.onnx'net = swin_t()weights = torch.load(pth_filename)#net.load_state_dict(weights)n..
2021-10-29 15:15:52 3965 15
原创 F.pad 的妙用
F.pad 的使用参考Pytorch之torch.nn.functional.pad函数详解F.pad 可用在通道扩充上。import torchimport torch.nn.functional as Fx = torch.randn(1,3,5,4)added_chan_num = 2use_pad = Trueif (not use_pad): z = torch.zeros(1,added_chan_num,5,4) x_a = torch.cat((x,z.
2021-10-28 15:00:55 819
原创 直观理解 torch.nn.Unfold
torch.nn.Unfold 是把batch中的数据按 C、Kernel_W、Kernel_H 打包,详细解释参考:PyTorch中torch.nn.functional.unfold函数使用详解本文主要是把 Unfold 返回的tensor的中间部分还原成 patches。# -*- coding:utf-8 -*-import cv2import torchimport numpy as npimg1 = cv2.imread('../128128/1.png')img2 =
2021-10-15 16:34:17 906
原创 pth 转 onnx 时出现的 gather、unsqueeze 等算子
带动态输入的view或者reshape转成onnx会有shape/gather/unsqueeze/concat算子。替换成 flatten 即可。def forward(self, inputs): x1 = self.conv1(inputs) x2 = self.conv2(x1) # 带动态输入的 view 或者 reshape 转成 onnx 会有shape/gather/unsqueeze/concat算子。 ...
2021-09-14 17:35:01 9110 9
原创 ubuntu16.04 安装 CUDA11.3
1、下载cuda_11.3.1_465.19.01_linux.run2、sudo ./cuda_11.3.1_465.19.01_linux.run
2021-06-07 15:44:47 2642
原创 安装 pycuda 出现 PEP517 的错误
执行:pip install pycuda出现:Building wheel for pycuda (PEP 517) ... error使用:pip install pycuda --no-binary :all:不解决问题。从源码编译,解决问题。1、下载pycuda-2021.1.tar.gz2、tar xfz pycuda-2021.1.tar.gz3、cd pycuda-2021.14、python3configure.py --cuda-root=/usr/lo..
2021-05-31 16:30:29 7130 3
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人