
Python Debug
洞幺01
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
解决pytorch模型加载时gpu id的限制
解决pytorch模型加载时gpu id的限制 问题描述 刚开始接触pytorch时,发现每次调用训练好的模型,总是被原来训练时使用的第几个gpu限制。 假如我训练模型时,用的是第3号gpu。那么在测试模型时,加载模型时直接使用GPU的话,就会被限制使用第3号gpu才能运行。 解决方案 首先将模型加载到cpu,然后再使用GPU。原创 2020-09-03 12:48:35 · 1138 阅读 · 1 评论 -
RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 0. Got 1and 3 解决方法
pytorch报错 RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 0. Got 1 and 3 in dimension 1 at /pytorch/aten/src/TH/generic/THTensorMath.cpp:3616 原因分析 使用DataLoader加载图...转载 2019-08-22 21:04:30 · 4536 阅读 · 0 评论 -
AttributeError: 'module' object has no attribute '_rebuild_tensor_v2' 解决方法
问题描述 用pytorch加载训练好的模型时,可能会遇到下面的问题: AttributeError: 'module' object has no attribute '_rebuild_tensor_v2' 原因 由于训练模型时使用的是新版本的pytorch,而加载时使用的是旧版本的pytorch。 解决方法 1、升级pytorch到适当的新版本 2、或者,在程序开头添加下面的代...转载 2019-08-22 20:48:35 · 1271 阅读 · 0 评论 -
pytorch中 gpu与gpu、gpu与cpu 在load时相互转化
问题描述 有时在加载已训练好的模型时,会出现 out of memory 的错误提示,但仔细检测使用的GPU卡并没有再用且内存也没有超出。 经查阅发现原来是训练模型时使用的GPU卡和加载时使用的GPU卡不一样导致的。个人感觉,因为pytorch的模型中是会记录有GPU信息的,所以有时使用不同的GPU加载时会报错。 解决方法 gpu之间的相互转换。即,将训练时的gpu卡转换为加载时的g...原创 2019-08-02 15:52:30 · 1006 阅读 · 0 评论 -
image file is truncated 解决方法
问题描述 在使用PIL处理图像时: from PIL import Image im=Image.open("pic.jpg") r,g,b=im.split() pic_bgr=Image.merge('RGB',(b,g,r)) pic_bgr.save('pic_bgr.jpg') 可能会遇到image file is truncated报错 解决方法 添加如下2句代码:...转载 2019-08-02 15:28:04 · 2831 阅读 · 0 评论 -
Variable conv1/weights already exists, disallowed. Did you mean to set reuse=True in VarScope? 解决方法
转载自:https://www.jianshu.com/p/fc11f32800f9 保存checkpoint后,尝试调用保存的模型: with tf.Session() as sess: print("Reading checkpoints...") ckpt = tf....转载 2019-03-05 18:00:27 · 4846 阅读 · 3 评论 -
tensorflow.python.framework.errors_impl.UnknownError: Failed to get convolution algorithm. 解决方法
一、问题描述 在使用tensorflow-gpu时,出现下面的错误: tensorflow.python.framework.errors_impl.UnknownError: Failed to get convolution algorithm. This is probably because cuDNN failed to initialize, so try looking to s...原创 2019-02-18 17:10:45 · 9575 阅读 · 1 评论 -
已安装tensorflow-gpu,但keras无法使用GPU加速 解决方法
一、问题 在安装了tensorflow-gpu后,调用keras无法使用gpu进行加速,反而使用CPU训练导致程序运行相对缓慢。 二、原因 若我们同时安装了tensorflow和tensorflow-gpu,使用keras时会默认调用tensorflow,从而无法使用GPU进行训练。 三、解决方法 同时卸载tensorflow、tensorflow-gpu和 keras; 然后,再安...原创 2019-02-17 16:25:48 · 15417 阅读 · 5 评论 -
AttributeError: module 'tensorflow.contrib.data' has no attribute 'TFRecordDataset' 解决方法
一、报错 当我们使用tf中的dataset时,可能会出现以下报错: 二、原因 tf版本不同导致的错误。 在编写代码时,使用的tf版本可能是TensorFlow 1.3。1.3版本的tf中,Dataset API是放在contrib包中; 但TensorFlow 1.4以后的版本,Dataset API已经从contrib包中移除了,而变成了核心API的一员。 故出现Attribute...原创 2019-02-16 16:44:49 · 7399 阅读 · 0 评论