2

我是初学者,在手动安装shogun的过程中遇到了一些问题。

情况是我打算用 shogun 的 Python 接口构建一个 MKL-SVM 模型,所以我通过以下方式安装了 shogun conda

conda install shogun

可以想象,我安装它看起来很安全顺利,但是当我在我的项目中调用这个包时,它喷涌而出,shogun.SVMLight()缺少该功能:

AttributeError: module 'shogun' has no attribute 'SVRLight'

我搜索了这个错误信息,并得到了一些建议,但它不起作用。于是,我又回到了官方的安装手册,有几句话引起了我的注意:

Anaconda 包包含大部分可选依赖项,但不是全部。

作者建议手工编译。

结果,我开始了漫长的旅程,充满了无尽的依赖缺失或不兼容的版本。我的安装步骤如下:

conda create -n shogun python=3.6
conda activate shogun
conda install cmake 
conda install -c creditx gcc-7
# conda install a series of other dependencies

# download source code and GPL license
git clone https://github.com/shogun-toolbox/shogun.git
cd shogun/src
git clone https://github.com/shogun-toolbox/shogun-gpl.git
cp shugun-gpl/* gpl/ -R

cd ..
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/export/home/zhouxiaocheng/miniconda3/envs/shogun -DPYTHON_EXECUTABLE=/export/home/zhouxiaocheng/miniconda3/envs/shogun/bin/python -DPYTHON_INCLUDE_DIR=/export/home/zhouxiaocheng/miniconda3/envs/shogun/include/python3.6m -DPYTHON_LIBRARY=/export/home/zhouxiaocheng/miniconda3/envs/shogun/lib/libpython3.6m.so -DINTERFACE_PYTHON=ON ..

然后,我得到了一些错误提示:

-- Summary of Configuration Variables
-- The following OPTIONAL packages have been found:

 * CCache
 * Doxygen (required version >= 1.8.6)
 * rxcpp
 * spdlog
 * Protobuf
 * HDF5
 * CURL
 * ZLIB
 * BZip2
 * LibLZMA
 * NLopt
 * Ctags
 * Sphinx
 * Pandoc

-- The following REQUIRED packages have been found:

 * SWIG (required version >= 3.0.12)
 * Threads
 * PythonLibs (required version == 3.6.10)
 * NumPy (required version >= 1.7)
 * PythonInterp
 * PLY

-- The following OPTIONAL packages have not been found:

 * OpenMP
 * CxaDemangle
 * Eigen3 (required version >= 3.1.2)
 * ViennaCL (required version >= 1.5.0)
 * TFLogger (required version >= 0.1.0)
 * BLAS
 * GLPK
 * LibArchive
 * CPLEX
 * ARPACK
 * Mosek
 * SNAPPY
 * LZO
 * LpSolve
 * ColPack
 * ARPREC

-- ===================================================================================================================
-- Integrations
--   OpenCV Integration is OFF   enable with -DOpenCV=ON
-- ===================================================================================================================
-- Interfaces
--   Python is ON
--   Octave is OFF               enable with -DINTERFACE_OCTAVE=ON
--   Java is OFF                 enable with -DINTERFACE_JAVA=ON
--   Perl is OFF                 enable with -DINTERFACE_PERL=ON
--   Ruby is OFF                 enable with -DINTERFACE_RUBY=ON
--   C# is OFF                   enable with -DINTERFACE_CSHARP=ON
--   R is OFF                    enable with -DINTERFACE_R=ON
--   Scala is OFF                enable with -DINTERFACE_SCALA=ON
--   CoreML is OFF               enable with -DINTERFACE_COREML=ON
-- ===================================================================================================================
-- To compile shogun type
--   make
-- 
-- To install shogun to /export/home/zhouxiaocheng/miniconda3/envs/shogun type
--   make install
-- 
-- or to install to a custom directory
--   make install DESTDIR=/my/special/path
--   (or rerun cmake with -DCMAKE_INSTALL_PREFIX=/my/special/path) to just change the prefix
-- ===================================================================================================================
-- Configuring done
CMake Warning at src/shogun/CMakeLists.txt:125 (add_library):
  Cannot generate a safe runtime search path for target shogun because files
  in some directories may conflict with libraries in implicit directories:

    runtime library [libcurl.so.4] in /export/home/zhouxiaocheng/miniconda3/envs/shogun/lib may be hidden by files in:
      /usr/local/lib
    runtime library [liblzma.so.5] in /export/home/zhouxiaocheng/miniconda3/envs/shogun/lib may be hidden by files in:
      /usr/local/lib

  Some of these libraries may not be found correctly.

我忽略了这些错误信息并执行了:

make install

它回来了:

[  0%] Built target ShogunVersionProtobuf
[  1%] Generating version header
[  1%] Built target version
[  1%] Generating /export/home/zhouxiaocheng/software/shogun/build/src/shogun/base/class_list.cpp
[  1%] Built target class_list
[  2%] Built target RapidJSON
[  2%] Built target ChunksProtobuf
[  3%] Built target bitsery
[  3%] Performing install step for 'Eigen3'
Install the project...
-- Install configuration: "Release"
-- Up-to-date: /export/home/zhouxiaocheng/software/shogun/build/src/shogun/third_party/eigen/signature_of_eigen3_matrix_library
CMake Error at cmake_install.cmake:65 (file):
  file cannot create directory: /usr/local/share/eigen3/cmake.  Maybe need
  administrative privileges.


make[3]: *** [install] Error 1
make[2]: *** [Eigen3/src/Eigen3-stamp/Eigen3-install] Error 2
make[1]: *** [src/shogun/CMakeFiles/Eigen3.dir/all] Error 2
make: *** [all] Error 2

我该如何解决这个问题,以便我可以SVMLight()成功调用该函数?

更新

我更改了以前的版本 v6.1.3,并再次尝试了该过程。出现了一些不同的错误。

Scanning dependencies of target libshogun
[  2%] Building CXX object src/shogun/CMakeFiles/libshogun.dir/base/Parallel.cpp.o
[  2%] Building CXX object src/shogun/CMakeFiles/libshogun.dir/base/Parameter.cpp.o
[  2%] Building CXX object src/shogun/CMakeFiles/libshogun.dir/base/SGObject.cpp.o
/export/home/zhouxiaocheng/software/shogun-shogun_6.1.3/src/shogun/base/SGObject.cpp:32:10: fatal error: rxcpp/operators/rx-filter.hpp: No such file or directory
 #include <rxcpp/operators/rx-filter.hpp>
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [src/shogun/CMakeFiles/libshogun.dir/base/SGObject.cpp.o] Error 1
make[1]: *** [src/shogun/CMakeFiles/libshogun.dir/all] Error 2
make: *** [all] Error 2

同时,我也在项目的 Github 问题页面上提交了一个关于它的问题。这两个问题中的任何一个都可以修复吗?

4

1 回答 1

0

在贡献者的帮助下,shogun终于编译安装成功。如果您在手动编译 shogun 时遇到任何类似的问题,请参考

于 2020-05-21T10:37:42.810 回答