Bug Record【持续更新】

问题目录

      • 问题1:RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0
      • 问题2:OSError: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.27' not found
      • 问题3:RuntimeError: result type Float can't be cast to the desired output type Long
      • 问题4:UnicodeDecodeError: 'gbk' codec can't decode byte 0xb4 in position 178: illegal multibyte sequence
      • 问题5:ValueError: could not convert string to float: ‘30.226,42.7354,1.90
      • 问题6:Command "python setup.py egg_info" failed with error code 1 in C:\Users\xxx\pip-build-ecnk45nt\pywinpty\
      • 问题7:Failed building wheel for numba
      • 问题8:AttributeError: 'numpy.float64' object has no attribute 'detach'
      • 问题9: Error in `python': free(): invalid pointer: 0x000055ca0b8d2e08
      • 问题10:AssertionError: Checkpoint detectron2://ImageNetPretrained/MSRA/R-101.pkl not found!


问题1:RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0

RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0

Bug Record【持续更新】_第1张图片
解决方案:

device = torch.device("cuda")
a = a.to(device) #指定设备

Bug Record【持续更新】_第2张图片
Bug Record【持续更新】_第3张图片

参考链接:

RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu on transormer

  • 张量与数组运算报错(Use Tensor.cpu() to copy the tensor to host memory first;RuntimeError: Expected all tensors to be on the same device)
  • Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!

问题2:OSError: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.27’ not found

Bug Record【持续更新】_第4张图片

Traceback (most recent call last):
File “test.py”, line 2, in
import open3d as o3d
File “/data/xinjianjia/anaconda3/envs/PointAugment/lib/python3.6/site-packages/open3d/init.py”, line 56, in
_CDLL(str(next((_Path(file).parent / ‘cpu’).glob(‘pybind*’))))
File “/data/xinjianjia/anaconda3/envs/PointAugment/lib/python3.6/ctypes/init.py”, line 348, in init
self._handle = _dlopen(self._name, mode)
OSError: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.27’ not found (required by /data/xinjianjia/anaconda3/envs/PointAugment/lib/python3.6/site-packages/open3d/cpu/pybind.cpython-36m-x86_64-linux-gnu.so)

解决方案:

将open3d的安装版本改为 0.8,执行如下指令:

pip uninstall open3d
pip install open3d==0.8

参考链接:

  • ImportError: /lib64/libm.so.6: version ‘GLIBC_2.27’ not found
  • OSError: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.27’ not found

问题3:RuntimeError: result type Float can’t be cast to the desired output type Long

参考链接:

  • Pytorch: RuntimeError: result type Float can’t be cast to the desired output type Long
  • Multi-label binary classification: result type Float can’t be cast to the desired output type Long

问题4:UnicodeDecodeError: ‘gbk’ codec can’t decode byte 0xb4 in position 178: illegal multibyte sequence

Bug Record【持续更新】_第5张图片
解决方案:

if you will open file with utf-8,then you need write:

open(file_name, 'r', encoding='UTF-8')

if you will open file with GBK,then you need do:

open(file_name, 'rb')

参考链接:

  • UnicodeDecodeError:‘gbk’ codec can’t decode byte 0x80 in position 0 illegal multibyte sequence

问题5:ValueError: could not convert string to float: ‘30.226,42.7354,1.90

Bug Record【持续更新】_第6张图片

Traceback (most recent call last):
File “exactFeature.py”, line 82, in
parts = loadSearch(’./data_search’)
File “exactFeature.py”, line 16, in loadSearch
part = np.loadtxt(path, delimiter=’ ')
File “/data/xinjianjia/anaconda3/envs/PointAugment/lib/python3.6/site-packages/numpy/lib/npyio.py”, line 1139, in loadtxt
for x in read_data(_loadtxt_chunksize):
File “/data/xinjianjia/anaconda3/envs/PointAugment/lib/python3.6/site-packages/numpy/lib/npyio.py”, line 1067, in read_data
items = [conv(val) for (conv, val) in zip(converters, vals)]
File “/data/xinjianjia/anaconda3/envs/PointAugment/lib/python3.6/site-packages/numpy/lib/npyio.py”, line 1067, in
items = [conv(val) for (conv, val) in zip(converters, vals)]
File “/data/xinjianjia/anaconda3/envs/PointAugment/lib/python3.6/site-packages/numpy/lib/npyio.py”, line 763, in floatconv
return float(x)
ValueError: could not convert string to float: ‘30.226,42.7354,1.905’

参考链接:

  • ValueError: could not convert string to float的解决方法

问题6:Command “python setup.py egg_info” failed with error code 1 in C:\Users\xxx\pip-build-ecnk45nt\pywinpty\

Bug Record【持续更新】_第7张图片
解决方案:

更新插件

python -m pip install --upgrade setupTools
python -m pip install --upgrade pip

参考链接:

  • 安装库提示Command “python setup.py egg_info” failed with error code 1 in C:\Users…错误

问题7:Failed building wheel for numba

Failed building wheel for numba
RuntimeError: Could not find a llvm-config binary. There are a number of reasons this could occur,
Failed building wheel for llvmlite
RuntimeError: Could not find a llvm-config binary. There are a number of reasons this could occur
Command “/data3/zhanghuiyong/anaconda3/envs/torch/bin/python -u -c “import setuptools, tokenize;file=’/tmp/pip-build-s9czqwfi/llvmlite/setup.py’;f=getattr(tokenize, ‘open’, open)(file);code=f.read().replace(’\r\n’, ‘\n’);f.close();exec(compile(code, file, ‘exec’))” install --record /tmp/pip-7rz1woww-record/install-record.txt --single-version-externally-managed --compile” failed with error code 1 in /tmp/pip-build-s9czqwfi/llvmlite/

Bug Record【持续更新】_第8张图片

解决方案:

升级 pip 版本

pip install --upgrade pip

在这里插入图片描述
Bug Record【持续更新】_第9张图片
Bug Record【持续更新】_第10张图片

参考链接:

  • 安装Numba: Failed building wheel for llvmlite

问题8:AttributeError: ‘numpy.float64’ object has no attribute ‘detach’

Bug Record【持续更新】_第11张图片
解决方法:

需要将变量转为 Tensor 类型。


问题9: Error in `python’: free(): invalid pointer: 0x000055ca0b8d2e08

*** Error in `python’: free(): invalid pointer: 0x000055ca0b8d2e08 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x777f5)[0x7f44e4dd37f5]
/lib/x86_64-linux-gnu/libc.so.6(+0x8038a)[0x7f44e4ddc38a]
/lib/x86_64-linux-gnu/libc.so.6(cfree+0x4c)[0x7f44e4de058c]


/PointAugment/lib/python3.6/lib-dynload/_lzma.cpython-36m-x86_64-linux-gnu.so
7f35c511b000-7f35c511e000 r-xp 00003000 08:11 58079482 /data/xinjianjia/anaconda3/envs/PointAugment/lib/python3.6/lib-dynload/_lzma.cpython-36m-x86_64-linux-gnu.so
7f35c511e000-7f35c511f000 r–p 00006000 08:11 58079482 /data/xinjianjia/anaconda3/envs/PointAugment/lib/python3.6/lib-dynload/_lzma.cpython-36m-x86_64-linux-gnu.so
7f35c511f000-7f35c5120000 —p 00007000 08:11 58079482 /data/xinjianjia/anaconda3/envs/PointAugment/lib/python3.6/lib-dynload/_lzma.cpython-36m-x86_64-linux-gnu.so
7f35c5120000-7f35c5121000 r–p 00007000 08:11 58079482 /data/xinjianjia/anaconda3/envs/PointAugment/lib/python3.6/lib-dynload/_lzma.cpython-36m-x86_64-linux-gnu.soAborted (core dumped)

Bug Record【持续更新】_第12张图片

Bug Record【持续更新】_第13张图片
解决方案:

需要将import open3d as o3d 的顺序放在 import torch 之前。

Bug Record【持续更新】_第14张图片


问题10:AssertionError: Checkpoint detectron2://ImageNetPretrained/MSRA/R-101.pkl not found!

Traceback (most recent call last):
File “tools/train_net.py”, line 225, in
args=(args,),
File “/data3/zhanghuiyong/detectron2-0.2.1/detectron2/engine/launch.py”, line 62, in launch
main_func(*args)
File “tools/train_net.py”, line 208, in main
trainer.resume_or_load(resume=args.resume)
File “/data3/zhanghuiyong/detectron2-0.2.1/detectron2/engine/defaults.py”, line 311, in resume__load
checkpoint = self.checkpointer.resume_or_load(self.cfg.MODEL.WEIGHTS, resume=resume)
File “/data3/zhanghuiyong/anaconda3/envs/SOTR/lib/python3.6/site-packages/fvcore/common/checkpot.py”, line 227, in resume_or_load
return self.load(path, checkpointables=[])
File “/data3/zhanghuiyong/anaconda3/envs/SOTR/lib/python3.6/site-packages/fvcore/common/checkpot.py”, line 153, in load
assert os.path.isfile(path), “Checkpoint {} not found!”.format(path)
AssertionError: Checkpoint detectron2://ImageNetPretrained/MSRA/R-101.pkl not found!

Bug Record【持续更新】_第15张图片

解决方案:
修改配置文件,将WEIGHTS:这一行的路径改为自己下载的权重文件路径。

Bug Record【持续更新】_第16张图片

Bug Record【持续更新】_第17张图片
在这里插入图片描述

你可能感兴趣的:(Bug,&,Solution,pytorch,人工智能,python)