hanlp 安装 DyNet2.0.1试验 论文 《Effective Neural Solution for Multi-Criteria Word Segmentation》

本文介绍了如何从源码编译安装Dynet2.0.1,并结合mkl提升CPU速度。通过安装后的Dynet,应用于HanLP的中文分词任务,探讨了《Effective Neural Solution for Multi-Criteria Word Segmentation》论文中的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >





安装配置Dynet2.0.1出现的问题:  undefined reference to `pthread_create'


https://github.com/hankcs/multi-criteria-cws/issues/1 使用的版本是2.0.1,这样只能从源代码安装, 安装步骤,作者也介绍了:

我是从源码编译安装的,第一步先安装mkl(可选,大幅提升CPU速度):
http://registrationcenter-download.intel.com/akdlm/irc_nas/tec/11544/l_mkl_2017.3.196.tgz

然后执行如下命令:

#!/usr/bin/env bash

git clone https://github.com/clab/dynet.git
hg clone https://bitbucket.org/eigen/eigen -r 346ecdb  # -r NUM specified a known working revision
cd dynet
git checkout 2.0.1
mkdir build
cd build
cmake .. -DEIGEN3_INCLUDE_DIR=../../eigen -DMKL=TRUE -DPYTHON=`which python3` -DMKL_ROOT=/opt/intel/mkl -DBACKEND=cuda
make -j 4
cd python
python ../../setup.py build --build-dir=.. --skip-build install


不过中间遇到了问题:
在cmake的时候,提示错误:
[ 74%] Building CXX object dynet/CMakeFiles/dynet.dir/ weight-decay.cc.o
Linking CXX shared library libgdynet.so
[ 74%] Built target gdynet
Linking CXX shared library libdynet.so
[ 74%] Built target dynet
make: *** [all] Error 2


Here is the complete error-log:

Determining if the pthread_create exist failed with the following output:
Change Dir: /DATA/USERS/irshad/ seqlearning/dynet/build/ CMakeFiles/CMakeTmp

Run Build Command:/usr/bin/make "cmTryCompileExec953060340/ fast"
/usr/bin/make -f CMakeFiles/ cmTryCompileExec953060340.dir/ build.make CMakeFiles/ cmTryCompileExec953060340.dir/ build
make[1]: Entering directory `/DATA/USERS/irshad/ seqlearning/dynet/build/ CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report /DATA/USERS/irshad/ seqlearning/dynet/build/ CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object CMakeFiles/ cmTryCompileExec953060340.dir/ CheckSymbolExists.c.o
/usr/bin/cc    -o CMakeFiles/ cmTryCompileExec953060340.dir/ CheckSymbolExists.c.o   -c /DATA/USERS/irshad/ seqlearning/dynet/build/ CMakeFiles/CMakeTmp/ CheckSymbolExists.c
Linking C executable cmTryCompileExec953060340
/usr/bin/cmake -E cmake_link_script CMakeFiles/ cmTryCompileExec953060340.dir/ link.txt --verbose=1
/usr/bin/cc       CMakeFiles/ cmTryCompileExec953060340.dir/ CheckSymbolExists.c.o  -o cmTryCompileExec953060340 -rdynamic
CMakeFiles/ cmTryCompileExec953060340.dir/ CheckSymbolExists.c.o: In function `main':
CheckSymbolExists.c:(.text+ 0x16): undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status
make[1]: *** [cmTryCompileExec953060340] Error 1
make[1]: Leaving directory `/DATA/USERS/irshad/ seqlearning/dynet/build/ CMakeFiles/CMakeTmp'
make: *** [cmTryCompileExec953060340/ fast] Error 2

File /DATA/USERS/irshad/ seqlearning/dynet/build/ CMakeFiles/CMakeTmp/ CheckSymbolExists.c:
/* */
#include <pthread.h>

int main(int argc, char** argv)
{
  (void)argv;
#ifndef pthread_create
  return ((int*)(&pthread_create))[ argc];
#else
  (void)argc;
  return 0;
#endif
}

Determining if the function pthread_create exists in the pthreads failed with the following output:
Change Dir: /DATA/USERS/irshad/ seqlearning/dynet/build/ CMakeFiles/CMakeTmp

Run Build Command:/usr/bin/make "cmTryCompileExec4252231607/ fast"
/usr/bin/make -f CMakeFiles/ cmTryCompileExec4252231607. dir/build.make CMakeFiles/ cmTryCompileExec4252231607. dir/build
make[1]: Entering directory `/DATA/USERS/irshad/ seqlearning/dynet/build/ CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report /DATA/USERS/irshad/ seqlearning/dynet/build/ CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object CMakeFiles/ cmTryCompileExec4252231607. dir/CheckFunctionExists.c.o
/usr/bin/cc   -DCHECK_FUNCTION_EXISTS= pthread_create   -o CMakeFiles/ cmTryCompileExec4252231607. dir/CheckFunctionExists.c.o   -c /usr/share/cmake-2.8/Modules/ CheckFunctionExists.c
Linking C executable cmTryCompileExec4252231607
/usr/bin/cmake -E cmake_link_script CMakeFiles/ cmTryCompileExec4252231607. dir/link.txt --verbose=1
/usr/bin/cc   -DCHECK_FUNCTION_EXISTS= pthread_create    CMakeFiles/ cmTryCompileExec4252231607. dir/CheckFunctionExists.c.o  -o cmTryCompileExec4252231607 -rdynamic -lpthreads
/usr/bin/ld: cannot find -lpthreads
collect2: error: ld returned 1 exit status
make[1]: *** [cmTryCompileExec4252231607] Error 1
make[1]: Leaving directory `/DATA/USERS/irshad/ seqlearning/dynet/build/ CMakeFiles/CMakeTmp'
make: *** [cmTryCompileExec4252231607/ fast] Error 2


按照google论坛的说法,是
DEIGEN3_INCLUDE_DIR使用的是相对路径,用绝对路径就好了。
以下是论坛的内容:
  
  
  
Re: undefined reference to `pthread_create' with -DBACKEND=cuda
3 名作者发布了 8 个帖子
 
 
Graham Neubig
17/1/4
其他收件人:  bhatir...@gmail.com
Hi Bhat,
Sorry about the late reply! Could you tell me which operating system you're trying to compile on?
Also, could you please delete and recreate the build directory, then run
cmake .. -DEIGEN3_INCLUDE_DIR=/DATA/ USERS/irshad/seqlearning/ eigen/ -DPYTHON=~/ltrc/bin/python -DBACKEND=cuda &> cmake.log
> make VERBOSE=1 &> make.log
And attach the resulting cmake.log and make.log files?
Graham
On Mon, Jan 2, 2017 at 6:18 AM, Bhat Irshad  <bhatir...@gmail.com> wrote:
Hi,
I tried to install dynet with cuda but got the following error:: undefined reference to `pthread_create'
cmake .. -DEIGEN3_INCLUDE_DIR=/DATA/ USERS/irshad/seqlearning/ eigen/ -DPYTHON=~/ltrc/bin/python -DBACKEND=cuda
make -j 12
.
.
.
[ 74%] Building CXX object dynet/CMakeFiles/dynet.dir/ weight-decay.cc.o
Linking CXX shared library libgdynet.so
[ 74%] Built target gdynet
Linking CXX shared library libdynet.so
[ 74%] Built target dynet
make: *** [all] Error 2
Here is the complete error-log:
Determining if the pthread_create exist failed with the following output:
Change Dir: /DATA/USERS/irshad/ seqlearning/dynet/build/ CMakeFiles/CMakeTmp
Run Build Command:/usr/bin/make "cmTryCompileExec953060340/ fast"
/usr/bin/make -f CMakeFiles/ cmTryCompileExec953060340.dir/ build.make CMakeFiles/ cmTryCompileExec953060340.dir/ build
make[1]: Entering directory `/DATA/USERS/irshad/ seqlearning/dynet/build/ CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report /DATA/USERS/irshad/ seqlearning/dynet/build/ CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object CMakeFiles/ cmTryCompileExec953060340.dir/ CheckSymbolExists.c.o
/usr/bin/cc    -o CMakeFiles/ cmTryCompileExec953060340.dir/ CheckSymbolExists.c.o   -c /DATA/USERS/irshad/ seqlearning/dynet/build/ CMakeFiles/CMakeTmp/ CheckSymbolExists.c
Linking C executable cmTryCompileExec953060340
/usr/bin/cmake -E cmake_link_script CMakeFiles/ cmTryCompileExec953060340.dir/ link.txt --verbose=1
/usr/bin/cc       CMakeFiles/ cmTryCompileExec953060340.dir/ CheckSymbolExists.c.o  -o cmTryCompileExec953060340 -rdynamic
CMakeFiles/ cmTryCompileExec953060340.dir/ CheckSymbolExists.c.o: In function `main':
CheckSymbolExists.c:(.text+ 0x16): undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status
make[1]: *** [cmTryCompileExec953060340] Error 1
make[1]: Leaving directory `/DATA/USERS/irshad/ seqlearning/dynet/build/ CMakeFiles/CMakeTmp'
make: *** [cmTryCompileExec953060340/ fast] Error 2
File /DATA/USERS/irshad/ seqlearning/dynet/build/ CMakeFiles/CMakeTmp/ CheckSymbolExists.c:
/* */
#include <pthread.h>
int main(int argc, char** argv)
{
  (void)argv;
#ifndef pthread_create
  return ((int*)(&pthread_create))[ argc];
#else
  (void)argc;
  return 0;
#endif
}
Determining if the function pthread_create exists in the pthreads failed with the following output:
Change Dir: /DATA/USERS/irshad/ seqlearning/dynet/build/ CMakeFiles/CMakeTmp
Run Build Command:/usr/bin/make "cmTryCompileExec4252231607/ fast"
/usr/bin/make -f CMakeFiles/ cmTryCompileExec4252231607. dir/build.make CMakeFiles/ cmTryCompileExec4252231607. dir/build
make[1]: Entering directory `/DATA/USERS/irshad/ seqlearning/dynet/build/ CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report /DATA/USERS/irshad/ seqlearning/dynet/build/ CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object CMakeFiles/ cmTryCompileExec4252231607. dir/CheckFunctionExists.c.o
/usr/bin/cc   -DCHECK_FUNCTION_EXISTS= pthread_create   -o CMakeFiles/ cmTryCompileExec4252231607. dir/CheckFunctionExists.c.o   -c /usr/share/cmake-2.8/Modules/ CheckFunctionExists.c
Linking C executable cmTryCompileExec4252231607
/usr/bin/cmake -E cmake_link_script CMakeFiles/ cmTryCompileExec4252231607. dir/link.txt --verbose=1
/usr/bin/cc   -DCHECK_FUNCTION_EXISTS= pthread_create    CMakeFiles/ cmTryCompileExec4252231607. dir/CheckFunctionExists.c.o  -o cmTryCompileExec4252231607 -rdynamic -lpthreads
/usr/bin/ld: cannot find -lpthreads
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值