Anaconda下 Gensim FAST_VERSION 无效的解决方法
来源:互联网 发布:电脑软件制作 编辑:程序博客网 时间:2024/06/06 11:49
环境:ubuntu 14.04, anaconda python 2.7
在Anaconda环境下安装gensim,直接安装是无法使用FAST_MODE的。因为anaconda中带有的scipy是没有BLAS原生库支持的。这样安装的gensim调用scipy中的算法时,无法使用C语言原生库进行计算,速度会比较慢。
表现出来的现象就是,
UserWarning: C extension not loaded for Word2Vec, training will be slow. Install a C compiler and reinstall gensim for fast training.
一开始遇到这个问题,我以为是因为在安装gensim时没有C编译器,所以相应类库无法从源码编译。但安装了build-essential
之后重新安装gensim,问题依旧存在。而且在使用pip或anaconda安装gensim时并没有编译的过程,即使下载源码编译并且使用 python setup.py build_ext --inplace
。于是断定问题应该出在间接调用的模块中。
经过搜索,在google group 中进一步定位到问题:
The scipy version (0.16.0) I am using does not have the
scipy.linalg.blas.fblas
module as it has been depracated. The Cython/C wrapper for the fast bit of word2vec and doc2vec however still expect that module to be there. Everything compiles fine but importinggensim.models.word2vec_inner
fails because it can’t find thefblas
module in scipy.
– Matti Lyra
至此,已经发现问题所在,是gensim间接调用scipy的线性代数模块时出现找不到C语言类库。gensim本身带有的错误提示具有相当的误导性,仅仅重新安装gensim本身并不会解决这个问题。
在ubuntu下直接使用pip安装scipy会出现无法找到Lapack支持的问题,网上列出了许多解决方法,如安装依赖库
sudo apt-get install libblas-dev liblapack-dev libatlas-base-dev gfortran
或使用apt-get install python-scipy
,靠apt-get来自动化解决依赖问题。但这些方法并不适用anaconda环境。
后来找到了一篇博文,介绍如何使用pip安装scipy,直接通过环境变量引导pip发现系统lapack支持:
pip uninstall numpy ## only if numpy is already installedpip uninstall scipy ## only if scipy is already installedexport LAPACK=/usr/lib/liblapack.soexport ATLAS=/usr/lib/libatlas.sopip install numpypip install scipy
最终解决了gensim.models.word2vec.FAST_VERSION的问题。
因为在网上找了许多资料,没有从头到尾解决这个问题的,所以记录下探究历程以及解决方式,方便后来人。
更多关于gensim性能优化的信息请参阅这篇博文。
- Anaconda下 Gensim FAST_VERSION 无效的解决方法
- Anaconda 32在windows下安装gensim
- Windows下安装python版的Word2Vec工具包gensim教程(基于Anaconda)
- python开发之anaconda【以及win7下安装gensim】
- python开发之anaconda【以及win7下安装gensim】
- linux下安装gensim的方法。
- VS2005下断点无效 解决方法
- VS2005下断点无效 解决方法
- windows 2000下"root/microsoftdns" 无效名称空间的解决方法
- Linux:Linux下网卡配置无效的解决方法
- FireFox下设置DIV的top和left无效解决方法
- Linux下cp命令 -f无效的解决方法
- IE8正式版下后台编辑器无效的解决方法
- Linux下cp命令 -f无效的解决方法
- option元素 display属性在IE下无效的解决方法
- web uploader在Firefox下上传点击无效的解决方法
- notifyDataSetChanged无效的解决方法
- Ubuntu下安装了Anaconda后无法导入第三方库的解决方法
- poj 1753 Flip Game
- mysql双主半同步的灾备测试结论
- ROM简单制作教程
- VMware虚拟机安装openstack注意事项
- android 自定义view二
- Anaconda下 Gensim FAST_VERSION 无效的解决方法
- Grunt自动化工具之初学笔记
- ZOJ Problem Set - 3758 素数
- 【POJ 3273】 Monthly Expense (二分)
- Jar mismatch! Fix your dependencies
- 0003.Tuper、array、map、文件操作
- Jsoup解析HTML实例及文档方法详解
- 白话空间统计十二:R语言对点数据分析的实现(2)可视化
- Burp Suite v1.6.20