目录
0. Pycharm安装
1. YOLO5 pip install -r requirements.txt安装在pycharm上安装失败
1.1 找不到文件
1. 2 提示网络连不上(类似下图),换用清华镜像
1.3 提示编码错误(如图)
2 pycocotools安装报错解决
2.1在线安装:
2.2 pycococtools的安装包
3 其他报错
4 python读取文件时,抛异常:
5. Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) should be the same
6.CUDA out of memory 解决办法
6.1 显存比较小
6.2 CPU比较差
6.3设置虚拟内存
7.解决pycharm中: OSError: [WinError 1455] 页面文件太小,无法完成操作 的问题
8.visual studio
8.1visual studio 2015安装教程
8.2WinX PyCharm安装opencv依赖Build Tools for Visual Studio问题。
9.Could not find a version that satisfies the requirement torchvision==0.8.2
10.pycharm无法加载文件 C:\Users\LY\Documents\WindowsPowerShell\profile.ps1,因为在此系统上禁止运行脚本
11. Autodl运行报错
11.1 项目运行找不到文件
11.2 数据集读取失败
11.3 yolov5-5.0运行失败,版本更新,需要修改\utils\loss.py 文件
12.UnicodeDecodeError: 'gbk' codec can't decode byte 0x98 in position 1093: illegal multibyte sequence
13.OMP: Hint This means that multiple copies of the OpenMP runtime have been linked into the program.
14. yolov5训练时出现WARNING: Ignoring corrupted image and/or label
15.RuntimeError: result type Float can‘t be cast to the desired output type long int64
炮哥带你学:https://blog.csdn.net/didiaopao/article/details/119787139https://blog.csdn.net/didiaopao/article/details/119787139
在pycharm的Terminal输入pip install -r requirements.txt这串命令时找不到文件,在requirements.txt所在的文件夹下安装。
在此路径下输入cmd,直接在命令窗口下载就行了
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
原因分析:未设置全为UTF-8 ,百度经验更改
win10 设置系统默认编码为utf-8-百度经验 (baidu.com)https://jingyan.baidu.com/article/25648fc1471e6a9191fd002e.html
直接在命令行和Anaconda Prompt里面:
pip install pycocotools
链接: https://pan.baidu.com/s/12UWZ2XZH1ZsBySkdVEJpsA?pwd=iv2b
提取码: iv2b
安装完直接解压复制其中pycocotools两个文件夹到conda环境。
放到Anaconda3\envs\pytorch\Lib\site-packages文件夹
TimeoutError: [WinError 10060]
由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败.
网络连接报错,可以添加
pycharm中: OSError: [WinError 1455] 页面文件太小,无法完成操作的问题
可以根据如下的操作来修改,在utils路径下找到datasets.py这个文件,将里面的第81行(yolov5是81行)里面的参数nw改为0就可以了。
'utf-8' codec can't decode byte 0x80 in position 64: invalid start byte
修改,读取文件时,以二进制文件读取
# 正确
open(file=file_full_name, mode='rb')
# 异常
open(file=file_full_name, mode='r')
在运行torch中出现这个错误。错误内容大概就是指输入类型是CPU(torch.FloatTensor),而参数类型是GPU(torch.cuda.FloatTensor)
首先,请先检查是否正确使用了CUDA。通常我们这样指定使用CUDA:
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
inputs.to(device)
把input这个tensor转换成了CUDA 类型,报错Input type (torch.cuda.FloatTensor) and weight type (torch.FloatTensor) should be the。
改正
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
inputs = inputs.to(device)
存比较小,或者处理其他的图片占用的更大,可以设置batch size为1/4/8/12等(尽量为4的倍数)
batch_size==4
workers==1
我的电脑——属性——高级系统设置——设置——虚拟内存
https://www.cnblogs.com/20183544-wangzhengshuai/p/14814459.html
https://blog.csdn.net/m0_37638031/article/details/78763956
https://blog.csdn.net/momodosky/article/details/118994554
查看pytorch版本和torchvision是否匹配,下载路径
(1条消息) pythorch版本和torchvision版本对应关系及torchvision安装_村西那条弯弯的河流的博客-CSDN博客_pytorch和torchvision版本对应关系https://blog.csdn.net/weixin_41267342/article/details/113878423
torchvision0.8.2对应pytorch1.7.1
第一步
pip install torch==1.7.1 -f https://download.pytorch.org/whl/torch_stable.html
第二步
pip install torchvision==0.8.2
(1条消息) pycharm终端提示无法加载文件 F:\Users\Administrator\PycharmProjects\pythonProject\venv\Scripts\activate.ps1,因为在_Cyan_汉堡包的博客-CSDN博客_无法加载文件 c:\users\administrator\pycharmprojects\pythhttps://blog.csdn.net/sinat_42414027/article/details/124916162(1条消息) 无法加载文件C:\Users\xxx\Documents\WindowsPowerShell\profile.ps1,因为在此系统上禁止运行脚本_Xavier Jiezou的博客-CSDN博客_https://aka.ms/pswindows
https://blog.csdn.net/qq_42951560/article/details/123859735
根据项目存放地址切换路径(我的在/root/autodl-tmp),避免一直cd filename
1. 点击远程主机后边的...
[ WARN:[email protected]] global /io/opencv/modules/imgcodecs/src/loadsave.cpp (239) findDecoder imread_(路径) can't open/read file: check file path/integrity
RuntimeError: result type Float can't be cast to the desired output type long int
1.Ctrl+F快捷检索‘for i in range(self.nl)’
for i in range(self.nl):
anchors = self.anchors[i] #更改前
for i in range(self.nl):
anchors, shape = self.anchors[i], p[i].shape # 更改后
2. Ctrl+F快捷检索‘indices.append’
a = t[:, 6].long() # anchor indices
indices.append((b, a, gj.clamp_(0, gain[3] - 1), gi.clamp_(0, gain[2] - 1))) # image, anchor, grid indices # 更改前
a = t[:, 6].long() # anchor indices
indices.append((b, a, gj.clamp_(0, shape[2] - 1), gi.clamp_(0, shape[3] - 1))) # image, anchor, grid # 更改后
报这个错,问题一般出在两个地方
1、编码设置,第一行没有设置
# _*_ coding:utf-8 _*_
2、处理数据时没有转码,如在open函数上,解决办法如下
with open("data.txt",'r',encoding='UTF-8') as data:
因为pytorch包中包含了名为libiomp5md.dll的文件,与Anaconda环境中的同一个文件出现了某种冲突,所以需要删除一个。
在yolov5-6.1\utils\datasets.py中的问题。
# if im.format.lower() in ('jpg', 'jpeg'):
# with open(im_file, 'rb') as f:
# f.seek(-2, 2)
# if f.read() != b'\xff\xd9': # corrupt JPEG
# ImageOps.exif_transpose(Image.open(im_file)).save(im_file, 'JPEG', subsampling=0, quality=100)
# msg = f'{prefix}WARNING: {im_file}: corrupt JPEG restored and saved'
找到6.1版报错的loss.py中最后那段for函数,将其整体替换为yolov5-master版中loss.py最后一段for函数即可正常运行
for i in range(self.nl):
anchors, shape = self.anchors[i], p[i].shape
gain[2:6] = torch.tensor(shape)[[3, 2, 3, 2]] # xyxy gain
# Match targets to anchors
t = targets * gain # shape(3,n,7)
if nt:
# Matches
r = t[..., 4:6] / anchors[:, None] # wh ratio
j = torch.max(r, 1 / r).max(2)[0] < self.hyp['anchor_t'] # compare
# j = wh_iou(anchors, t[:, 4:6]) > model.hyp['iou_t'] # iou(3,n)=wh_iou(anchors(3,2), gwh(n,2))
t = t[j] # filter
# Offsets
gxy = t[:, 2:4] # grid xy
gxi = gain[[2, 3]] - gxy # inverse
j, k = ((gxy % 1 < g) & (gxy > 1)).T
l, m = ((gxi % 1 < g) & (gxi > 1)).T
j = torch.stack((torch.ones_like(j), j, k, l, m))
t = t.repeat((5, 1, 1))[j]
offsets = (torch.zeros_like(gxy)[None] + off[:, None])[j]
else:
t = targets[0]
offsets = 0
# Define
bc, gxy, gwh, a = t.chunk(4, 1) # (image, class), grid xy, grid wh, anchors
a, (b, c) = a.long().view(-1), bc.long().T # anchors, image, class
gij = (gxy - offsets).long()
gi, gj = gij.T # grid indices
# Append
indices.append((b, a, gj.clamp_(0, shape[2] - 1), gi.clamp_(0, shape[3] - 1))) # image, anchor, grid
tbox.append(torch.cat((gxy - gij, gwh), 1)) # box
anch.append(anchors[a]) # anchors
tcls.append(c) # class