我已经在 Oracle VirtualBox 64 位机器实例上安装了最新的 Ubuntu Server,主机是 Windows 10 和 64 位操作系统。
我使用一篇随机在 Google 上搜索到的文章安装了一个“精简”桌面环境。一切运行正常,包括网络连接,事实上,我是在 Ubuntu 实例的 Firefox 中发帖的。
此外,另一个先决条件是著名的线性代数库 ATLAS,以下是我安装它的说明: https://gist.github.com/sangheestyle/ca8ef7796aefadad8773
需要在 Google 上搜索安装其他先决条件等。我认为可能存在更简单的安装方法,但我可能会将其与我做过的其他事情混淆。无论如何,这些说明相当简单,就像我下面说的那样,构建 zipHMMlib(我遇到的问题)似乎发现 ATLAS 没问题,或者它的 make 错误似乎与我的 ATLAS 安装无关。
我的问题是根据以下说明进行的:
https://github.com/mailund/ziphmm
它真的很棒,HMM 库通过记录重复的输入序列来减少计算时间。在某些情况下,学习一个 HMM 模型在标准实现上需要 9 个小时,而使用这个库只需要 8 分钟,研究论文就是如此报告的。
无论如何,我已经尝试了这里的发布代码:
https://birc.au.dk/software/ziphmm/
还有 git 代码。我下载或使用 git 存储库将源代码复制到我的服务器,使用cd
进入下载的目录(如果需要,解压后)并运行上述 github 链接上的说明。
确切地说,它们是:
$ cd <path to library>/zipHMM-1.0.1/
zipHMM-1.0.1 $ cmake .
zipHMM-1.0.1 $ make
zipHMM-1.0.1 $ bin/calibrate
zipHMM-1.0.1 $ make test
zipHMM-1.0.1 $ make install
现在,使用 安装 Python Dev 库后apt-get install
,cmake .
命令就可以顺利通过。
但是当我运行make
它时,它开始构建一段时间,生成大量.o
文件,这是一个好兆头!然后它失败了(总的来说 - 我包含了所有内容,因此请参阅下面的底线):
oot@mechanikos-industries-ubuntu-server:/home/enjoysmath/zipHMM-1.0.1# make
[ 20%] Built target zipHMM
[ 21%] Building CXX object zipHMM/CMakeFiles/pyZipHMM.dir/pyZipHMM.cpp.o
[ 21%] Building CXX object zipHMM/CMakeFiles/pyZipHMM.dir/forwarder.cpp.o
[ 22%] Building CXX object zipHMM/CMakeFiles/pyZipHMM.dir/simple_stop_forwarder.cpp.o
[ 23%] Building CXX object zipHMM/CMakeFiles/pyZipHMM.dir/matrix.cpp.o
[ 24%] Building CXX object zipHMM/CMakeFiles/pyZipHMM.dir/seq_io.cpp.o
[ 24%] Building CXX object zipHMM/CMakeFiles/pyZipHMM.dir/hmm_io.cpp.o
[ 25%] Building CXX object zipHMM/CMakeFiles/pyZipHMM.dir/io_utils.cpp.o
[ 26%] Building CXX object zipHMM/CMakeFiles/pyZipHMM.dir/prob_spaces.cpp.o
[ 26%] Building CXX object zipHMM/CMakeFiles/pyZipHMM.dir/hmm_utils.cpp.o
[ 27%] Building CXX object zipHMM/CMakeFiles/pyZipHMM.dir/PThreadProcessingDevice.cpp.o
[ 28%] Building CXX object zipHMM/CMakeFiles/pyZipHMM.dir/performance_description.cpp.o
[ 28%] Building CXX object zipHMM/CMakeFiles/pyZipHMM.dir/Stage1JobControl.cpp.o
[ 29%] Building CXX object zipHMM/CMakeFiles/pyZipHMM.dir/posterior_decoding.cpp.o
[ 30%] Building CXX object zipHMM/CMakeFiles/pyZipHMM.dir/viterbi.cpp.o
[ 31%] Building CXX object zipHMM/CMakeFiles/pyZipHMM.dir/debug.cpp.o
[ 31%] Linking CXX shared library libpyZipHMM.so
[ 31%] Built target pyZipHMM
[ 32%] Linking CXX executable ../bin/calibrate
/usr/bin/ld: CMakeFiles/calibrate.dir/PThreadProcessingDevice.cpp.o: in function `zipHMM::PThreadProcessingDevice::computeSymbol2ScaleAndSymbol2Matrix(zipHMM::Stage1JobControl&)':
/home/enjoysmath/zipHMM-1.0.1/zipHMM/PThreadProcessingDevice.cpp:83: undefined reference to `pthread_create'
/usr/bin/ld: CMakeFiles/calibrate.dir/PThreadProcessingDevice.cpp.o: in function `zipHMM::PThreadProcessingDevice::likelihoodVector(zipHMM::Stage2JobControl&)':
/home/enjoysmath/zipHMM-1.0.1/zipHMM/PThreadProcessingDevice.cpp:183: undefined reference to `pthread_create'
/usr/bin/ld: CMakeFiles/calibrate.dir/PThreadProcessingDevice.cpp.o: in function `zipHMM::PThreadProcessingDevice::likelihoodMatrix(zipHMM::Stage2JobControl&)':
/home/enjoysmath/zipHMM-1.0.1/zipHMM/PThreadProcessingDevice.cpp:187: undefined reference to `pthread_create'
/usr/bin/ld: CMakeFiles/calibrate.dir/PThreadProcessingDevice.cpp.o: in function `zipHMM::PThreadProcessingDevice::join()':
/home/enjoysmath/zipHMM-1.0.1/zipHMM/PThreadProcessingDevice.cpp:466: undefined reference to `pthread_join'
collect2: error: ld returned 1 exit status
make[2]: *** [zipHMM/CMakeFiles/calibrate.dir/build.make:268: bin/calibrate] Error 1
make[1]: *** [CMakeFiles/Makefile2:217: zipHMM/CMakeFiles/calibrate.dir/all] Error 2
make: *** [Makefile:182: all] Error 2
因此,在谷歌上搜索时,人们说当发生这种情况时,您需要CFLAGS
或CXX_FLAGS
包括-lpthread
。我尽可能手动验证CXX_FLAGS
发送给 make 指令的上述失败的 .o 文件是否正确。我编辑了flags.make
隐藏在某个目录中的 (通过 grepping 找到)并发现它就-lpthread
在那里。我还使用以下命令输出了 CMake 构建标志:
root@mechanikos-industries-ubuntu-server:/home/enjoysmath/zipHMM-1.0.1# cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .
-- CXX_FLAGS: -Wall -Wconversion -O3 -g -lpthread
-- PYTHON_SITE_PACKAGES:
-- Configuring done
-- Generating done
-- Build files have been written to: /home/enjoysmath/zipHMM-1.0.1
因此,显然它已正确设置以包含 pthread 支持。那么我如何才能找到有关为什么这些行无法正确生成的更多信息?网络上绝对没有关于这个特定库的指导,因为我猜除了原始创建者之外,没有人真正使用过它。我可以尝试在 github 页面上发布问题,但就像我说的那样,最新的帖子是 5 年前的,所以......我认为这是一个更好的地方,我认为对于遇到过类似构建问题的人来说,这很容易修复。
所以请帮忙。我真的很想使用这个最佳的 HMM 库。
如果您能帮助我使其运行,我就可以分叉他们的存储库并保留它的工作副本并帮助其他人等。
答案1
由于我收到错误输出,我将其插入以下命令:
make --just-print | grep /PThreadProcessingDevice.cpp.o
输出如下内容:
/home/enjoysmath/zipHMM-1.0.1# make --just-print | grep /PThreadProcessingDevice.cpp.o
/usr/bin/cmake -E cmake_echo_color --switch= --green --progress-dir=/home/enjoysmath/zipHMM-1.0.1/CMakeFiles --progress-num= "Building CXX object zipHMM/CMakeFiles/build_forwarder.dir/PThreadProcessingDevice.cpp.o"
cd /home/enjoysmath/zipHMM-1.0.1/zipHMM && /usr/bin/c++ -I/home/enjoysmath/zipHMM-1.0.1 -I/com/extra/ATLAS/3.9.84/i`enter code here`nclude -I/usr/include/python3.9 -Wall -Wconversion -O3 -g -lpthread -o CMakeFiles/build_forwarder.dir/PThreadProcessingDevice.cpp.o -c /home/enjoysmath/zipHMM-1.0.1/zipHMM/PThreadProcessingDevice.cpp
/usr/bin/cmake -E cmake_echo_color --switch= --green --progress-dir=/home/enjoysmath/zipHMM-1.0.1/CMakeFiles --progress-num= "Building CXX object zipHMM/CMakeFiles/forward.dir/PThreadProcessingDevice.cpp.o"
cd /home/enjoysmath/zipHMM-1.0.1/zipHMM && /usr/bin/c++ -I/home/enjoysmath/zipHMM-1.0.1 -I/com/extra/ATLAS/3.9.84/include -I/usr/include/python3.9 -Wall -Wconversion -O3 -g -lpthread -o CMakeFiles/forward.dir/PThreadProcessingDevice.cpp.o -c /home/enjoysmath/zipHMM-1.0.1/zipHMM/PThreadProcessingDevice.cpp
/usr/bin/cmake -E cmake_echo_color --switch= --green --progress-dir=/home/enjoysmath/zipHMM-1.0.1/CMakeFiles --progress-num= "Building CXX object zipHMM/CMakeFiles/cpp_example.dir/PThreadProcessingDevice.cpp.o"
cd /home/enjoysmath/zipHMM-1.0.1/zipHMM && /usr/bin/c++ -I/home/enjoysmath/zipHMM-1.0.1 -I/com/extra/ATLAS/3.9.84/include -I/usr/include/python3.9 -Wall -Wconversion -O3 -g -lpthread -o CMakeFiles/cpp_example.dir/PThreadProcessingDevice.cpp.o -c /home/enjoysmath/zipHMM-1.0.1/zipHMM/PThreadProcessingDevice.cpp
/usr/bin/cmake -E cmake_echo_color --switch= --green --progress-dir=/home/enjoysmath/zipHMM-1.0.1/CMakeFiles --progress-num=68 "Building CXX object zipHMM/CMakeFiles/test_device_io.dir/PThreadProcessingDevice.cpp.o"
cd /home/enjoysmath/zipHMM-1.0.1/zipHMM && /usr/bin/c++ -I/home/enjoysmath/zipHMM-1.0.1 -I/com/extra/ATLAS/3.9.84/include -I/usr/include/python3.9 -Wall -Wconversion -O3 -g -lpthread -o CMakeFiles/test_device_io.dir/PThreadProcessingDevice.cpp.o -c /home/enjoysmath/zipHMM-1.0.1/zipHMM/PThreadProcessingDevice.cpp
/usr/bin/cmake -E cmake_echo_color --switch= --green --progress-dir=/home/enjoysmath/zipHMM-1.0.1/CMakeFiles --progress-num=78 "Building CXX object zipHMM/CMakeFiles/test_forwarder.dir/PThreadProcessingDevice.cpp.o"
cd /home/enjoysmath/zipHMM-1.0.1/zipHMM && /usr/bin/c++ -I/home/enjoysmath/zipHMM-1.0.1 -I/com/extra/ATLAS/3.9.84/include -I/usr/include/python3.9 -Wall -Wconversion -O3 -g -lpthread -o CMakeFiles/test_forwarder.dir/PThreadProcessingDevice.cpp.o -c /home/enjoysmath/zipHMM-1.0.1/zipHMM/PThreadProcessingDevice.cpp
root@mechanikos-industries-ubuntu-server:/home/enjoysmath/zipHMM-1.0.1#
如您所见,每个编译指令-lpthread
都已传入,但我flags.make
在此之前已编辑如下:
# compile CXX with /usr/bin/c++
CXX_DEFINES =
CXX_INCLUDES = -I/home/enjoysmath/zipHMM-1.0.1 -I/com/extra/ATLAS/3.9.84/include -I/usr/include/python3.9
CXX_FLAGS = -Wall -Wconversion -O3 -g -pthread
请注意-pthread
而不是-lpthread
。这就是我所做的更改,但 make 命令不知何故使用了先前的设置。但至少我了解了它发送的内容,并且使用-pthread
而不是 值得一试,所以我现在会尝试弄清楚,或者新的问题是:make 从哪里获取其标志?
通过运行后lpthread
用替换所有出现的 来神奇地构建它:pthread
cmake .
grep -rl lpthread ./ | xargs sed -i 's/lpthread/pthread/g'
我还是不确定cmake
应该将其发送到哪里lpthread
。
成功构建的输出在 Ubuntu 服务器的标准精简桌面上应该如下所示:
我在这里对存储库进行了分叉:
https://github.com/enjoysmath/ziphmm
将上述针对 Ubuntu 的更正放入 readme markdown 中。
我会尽力维护这个库,所以如果您有任何问题,请在该 github 页面上链接的问题论坛上发帖。