Can not run simple example with LIBSVM

I am trying to run this code:

using LIBSVM

x = randn(20, 2)

labels = repeat([-1,1], 10)

model = svmtrain(x', labels)

I tried to run it in JupyterLab, VSCode and REPL but it gives me a definitive error (the kernel dies or the REPL “disappears”). What am I doing wrong?

Tell us more about your environment, this example works fine for me.

(jl_5cd6Nm) pkg> st
Status `/tmp/jl_5cd6Nm/Project.toml`
  [b1bec4e5] LIBSVM v0.8.0

julia> versioninfo()
Julia Version 1.8.4
Commit 00177ebc4fc (2022-12-23 21:32 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 8 × Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-13.0.1 (ORCJIT, skylake)
  Threads: 1 on 8 virtual cores
Environment:
  JULIA_REVISE_INCLUDE = 1

julia> model = svmtrain(x', labels)
LIBSVM.SVM{Int64, LIBSVM.Kernel.KERNEL}(SVC, LIBSVM.Kernel.RadialBasis, nothing, 2, 20, 2, [-1, 1], Int32[1, 2], Float64[], Int32[], LIBSVM.SupportVectors{Vector{Int64}, Matrix{Float64}}(20, Int32[10, 10], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1.2984038909827587 1.2314498929516222 … -0.4990577254587847 -0.09934096595409833; -0.014358562547698217 -1.9769048777401381 … -0.2480222745773928 1.30343048263463], Int32[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20], LIBSVM.SVMNode[LIBSVM.SVMNode(1, 1.2984038909827587), LIBSVM.SVMNode(1, 1.2314498929516222), LIBSVM.SVMNode(1, -0.206732488395149), LIBSVM.SVMNode(1, -1.9688888354825855), LIBSVM.SVMNode(1, -0.590382885521247), LIBSVM.SVMNode(1, 0.8629190829271126), LIBSVM.SVMNode(1, 0.23643891644794354), LIBSVM.SVMNode(1, -0.8949879434481387), LIBSVM.SVMNode(1, -1.4686834999647989), LIBSVM.SVMNode(1, -0.18113993283), LIBSVM.SVMNode(1, 0.2104238266297134), LIBSVM.SVMNode(1, -0.12033216946780083), LIBSVM.SVMNode(1, -0.6641647465543847), LIBSVM.SVMNode(1, 0.6003935923333642), LIBSVM.SVMNode(1, -0.2732474439472201), LIBSVM.SVMNode
(1, -1.0989256954887598), LIBSVM.SVMNode(1, -1.2754702362317445), LIBSVM.SVMNode(1, -1.078179589505265), LIBSVM.SVMNode(1, -0.4990577254587847), LIBSVM.SVMNode(1, -0.09934096595409833)]), 0.0, [0.22032220867321212; 0.7477130600665552; … ; -1.0; -0.7999919624631144;;], Float64[], Float64[], [-0.37285653013209946], 3, 0.5, 200.0, 0.001, 1.0,
0.5, 0.1, true, false)
Status `C:\Users\sbac\Dropbox\JULIA\ISLR_sof\Project.toml`
  [b1bec4e5] LIBSVM v0.8.0

julia> versioninfo()
Julia Version 1.8.5
Commit 17cfb8e65e (2023-01-08 06:45 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)      
  CPU: 4 × Intel(R) Core(TM) i5-4460  CPU @ 3.20GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-13.0.1 (ORCJIT, haswell)
  Threads: 1 on 4 virtual cores
Environment:
  JULIA_EDITOR = code
  JULIA_NUM_THREADS =
  JULIA_PKG_SERVER = https://juliahub.com

I think it’s a problem with my Windows config. I tried in Linux (WSL2) and it worked.

julia> versioninfo()
Julia Version 1.8.5
Commit 17cfb8e65ea (2023-01-08 06:45 UTC)
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 4 × Intel(R) Core™ i5-4460 CPU @ 3.20GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-13.0.1 (ORCJIT, haswell)
Threads: 1 on 4 virtual cores

Sounds like your hitting this known issue with Julia: Julia 1.8.4, 1.8.5 and 1.9.0-beta3 crash with XGBoost.jl and LIBSVM.jl under Windows 11 · Issue #48187 · JuliaLang/julia · GitHub

1 Like