word2vec centos 安装

google的下载地址国内已无法连接,下载地址http://download.csdn.net/detail/u013378306/9741439
安装步骤
1、下载word2vec,其目录结构如下:

2、进入word2vec所在目录,使用make指令进行安装
make 



可以发现在安装的时候,会出现如下error:
gcc word2vec.c -o word2vec -lm -pthread -Ofast -march=native -Wall -funroll-loops -Wno-unused-result   
cc1: error: invalid option argument ?Ofast?   
cc1: warning: unrecognized command line option “-Wno-unused-result”   
make: *** [word2vec] Error 1  


这是因为该系统的gcc不支持Ofast选项的原因。
3、编辑makefile文件,更改gcc安装选项
 
vi ./makefile   


word2vec的makefile源码如下:
  
    CC = gcc   
    #The -Ofast might not work with older versions of gcc; in that case, use -O2   
    CFLAGS = -lm -pthread -Ofast -march=native -Wall -funroll-loops -Wno-unused-result   
        
    all: word2vec word2phrase distance word-analogy compute-accuracy   
        
    word2vec : word2vec.c   
     $(CC) word2vec.c -o word2vec $(CFLAGS)   
    word2phrase : word2phrase.c   
     $(CC) word2phrase.c -o word2phrase $(CFLAGS)   
    distance : distance.c   
     $(CC) distance.c -o distance $(CFLAGS)   
    word-analogy : word-analogy.c   
     $(CC) word-analogy.c -o word-analogy $(CFLAGS)   
    compute-accuracy : compute-accuracy.c   
     $(CC) compute-accuracy.c -o compute-accuracy $(CFLAGS)   
     chmod +x *.sh   
        
    clean:   
     rm -rf word2vec word2phrase distance word-analogy compute-accuracy  

注意观察,第二行:
     #The -Ofast might not work with older versions of gcc; in that case, use -O2
     google的工程师这里有写到相关注意事项,告诉开发者,-Ofast安装选项,可能对于旧版本的gcc不支持,如果在这种情况下,需要将-Ofast改为-O2,所以将第三行CFLAGS = -lm -pthread -Ofast -march=native -Wall -funroll-loops -Wno-unused-result更改为CFLAGS = -lm -pthread -O2-march=native -Wall -funroll-loops -Wno-unused-result。
4、使用make指令安装通过
 
make  


安装通过后的内容为:
    gcc word2vec.c -o word2vec -lm -pthread -Ofast -march=native -Wall -funroll-loops -Wno-unused-result  
    gcc word2phrase.c -o word2phrase -lm -pthread -Ofast -march=native -Wall -funroll-loops -Wno-unused-result  
    gcc distance.c -o distance -lm -pthread -Ofast -march=native -Wall -funroll-loops -Wno-unused-result  
    gcc word-analogy.c -o word-analogy -lm -pthread -Ofast -march=native -Wall -funroll-loops -Wno-unused-result  
    gcc compute-accuracy.c -o compute-accuracy -lm -pthread -Ofast -march=native -Wall -funroll-loops -Wno-unused-result  
    chmod +x *.sh  


按照上述操作即可成功安装Word2vec。

你可能感兴趣的:(word2vec centos 安装)