目录
- 1. TypeError: not all arguments converted during string formatting
- 2. PyTorch利用TensorboardX可视化时,出现的url无法访问的问题
- 3. 使用TensorFlow2.0运行程序报错:ValueError: TypeError: len() of unsized object
- 4. 使用PyTroch时遇到了之前的程序用不了,并且报错:ImportError: cannot import name 'PILLOW_VERSION' from 'PIL'
- 5. 在使用conda命令安装第三方库时,无法安装,并出现错误:RemoveError: 'setuptools' is a dependency of conda and cannot be removed from conda's operating environment
- 6. 运行tensorflow程序时出现警告:Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
- 7.运行tensorflow程序出现错误:OSError: Unable to open file (truncated file: eof = 417792, sblock->base_add...
- 8.TypeError: 'tuple' object is not callable
- 9.用opencv读入图片,matplotlib的pyplot显示图片颜色不正常
- 10.用tensorflow GPU版本时出现警告:CUDNN_STATUS_ALLOC_FAILED
1. TypeError: not all arguments converted during string formatting
这个是参数类型不对应的问题,在用%传递参数时出现。
解决办法:
将%用.format()代替。
2. PyTorch利用TensorboardX可视化时,出现的url无法访问的问题
采用的命令为:tensorboard --logdir Jul22_18-03-19_WH-PC19012AlexNet
出现的url为:TensorBoard 1.14.0 at http://DESKTOP-UTFSE8L:6006/ (Press CTRL+C to quit)
而这个url无法访问。
解决办法:这是由于版本的原因,无法直接用6006端口可视化。将命令改为:
tensorboard --logdir=runs文件夹所在的路径 --host=127.0.0.1
例如:
tensorboard --logdir=E:\Pycharm\project\project_pytorch.idea --host=127.0.0.1
运行后,产生的url可以正常访问pytorch的网络模型的可视化结构了。
3. 使用TensorFlow2.0运行程序报错:ValueError: TypeError: len() of unsized object
这个是由于numpy版本太高,和tensorflow2.0不兼容导致的。我用的是numpy17.0.0版本,降级到1.16.4版本。
pip install numpy == 1.16.4
4. 使用PyTroch时遇到了之前的程序用不了,并且报错:ImportError: cannot import name ‘PILLOW_VERSION’ from ‘PIL’
这是由于前两天更新了pillow到了7.0.0,而导致不匹配的问题,7.0.0版本没有 PILLOW_VERSION 的值,需要降级。
先卸载pillow,pip uninstall pillow
再指定版本 pip install pillow==6.1.0
重新运行,可以正常运行
5. 在使用conda命令安装第三方库时,无法安装,并出现错误:RemoveError: ‘setuptools’ is a dependency of conda and cannot be removed from conda’s operating environment
可以尝试以下两种办法:
- conda update --force conda
- conda install -c anaconda setuptools
6. 运行tensorflow程序时出现警告:Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
这只是一个警告,一般不会产生影响,可以选择不管,也可以通过如下的代码屏蔽这个警告:
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
运行后就没有警告了
7.运行tensorflow程序出现错误:OSError: Unable to open file (truncated file: eof = 417792, sblock->base_add…
这是由于之前下载的模型未完成,无法打开,需要把之前下载的模型删除,重新下载才能继续。路径是:C:\Users\adminPC.keras\models
8.TypeError: ‘tuple’ object is not callable
这是由于shape出错,应该为img.shape[0]或img.shape能显示数组大小。
9.用opencv读入图片,matplotlib的pyplot显示图片颜色不正常
这是由于opencv读入是BGR格式的图片,而pyplot显示的是RGB格式的图片,因此可能出现反色问题。解决办法:
用opencv的cvtColor函数转换一下再显示。。
image = cv2.cvtColor(img,cv2.COLOR_BGR2RGB)
plt.imshow(image)
10.用tensorflow GPU版本时出现警告:CUDNN_STATUS_ALLOC_FAILED
这是因为只能用gpu同时运行1个程序,应该将其他程序关闭。。