在Clojure中使用尼安德特人时MKL库错误

时间:2019-06-28 21:03:42

标签: clojure intel-mkl

我正在尝试在Clojure中使用Neanderthal库,但是在执行任何rand-normal!rand-uniform!时仍然出现错误。我已经安装了英特尔MKL库,并以mklvars.bat文件的形式执行mklvars intel64来设置环境变量,但是随后我检查了环境。变量,由于它没有添加任何新内容,因此我手动添加了它们。我该怎么做才能使其正常工作?

我正在使用Windows 10 64位。

这是我的代码:

(ns testing-grounds.neanderthal.core
  (:gen-class)
  (:require [uncomplicate.neanderthal
             [native :refer [dv dge fv fge native-float]]
             [core :refer [submatrix native dot mm ge]]
             [math :refer [sqrt log sin pi sqr]]
             [random :refer [rand-normal! rand-uniform! rng-state]]]))

(def x (dv 1 2 3))
;; => #'testing-grounds.neanderthal.core/x

(def y (dv 10 20 30))
;; => #'testing-grounds.neanderthal.core/y

(dot x y)
;; => 140.0

(def a (dge 3 2 [1 2 3 4 5 6]))
;; => #'testing-grounds.neanderthal.core/a

(def b (dge 2 3 [10 20 30 40 50 60]))
;; => #'testing-grounds.neanderthal.core/b

(mm a b)
;; => #RealGEMatrix[double, mxn:3x3, layout:column, offset:0]
;;    ▥       ↓       ↓       ↓       ┓
;;    →      90.00  190.00  290.00
;;    →     120.00  260.00  400.00
;;    →     150.00  330.00  510.00
;;    ┗                               ┛

(def x
  "Define an empty float vector"
  (fv 5))
;; => #'testing-grounds.neanderthal.core/x

(rand-uniform! x) 
; Error

(def a (fge 3 2))
;; => #'testing-grounds.neanderthal.core/a

(rand-normal! 33 2.5 a) 
; Error

project.clj

(defproject testing-grounds "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "LATEST"]
                 [uncomplicate/neanderthal "LATEST"]
                 [incanter "LATEST"]
                 [org.clojure/tools.nrepl "LATEST"]
                 [nrepl "LATEST"]
                 [cider/cider-nrepl "LATEST"]
                 ]
  :plugins [[cider/cider-nrepl "LATEST"]]
  :java-cmd "C:/Users/user/Downloads/jdk-12.0.1/bin/java"
  :jvm-opts ["--add-opens=java.base/jdk.internal.ref=ALL-UNNAMED"]
  :main ^:skip-aot testing-grounds.core
  :target-path "target/%s"
  :profiles {:uberjar {:aot :all}})

错误:

  Show: Project-Only All 
  Hide: Clojure Java REPL Tooling Duplicates  (0 frames hidden)

1. Unhandled clojure.lang.ExceptionInfo
   MKL error.
   {:error-code -1140}
                   mkl.clj:  823  uncomplicate.neanderthal.internal.host.mkl.FloatVectorEngine/rand_uniform
                random.clj:   42  uncomplicate.neanderthal.random/rand-uniform!
                random.clj:   37  uncomplicate.neanderthal.random/rand-uniform!
                      REPL:   28  testing-grounds.neanderthal.core/eval33584
                      REPL:   28  testing-grounds.neanderthal.core/eval33584
             Compiler.java: 7177  clojure.lang.Compiler/eval
             Compiler.java: 7132  clojure.lang.Compiler/eval
                  core.clj: 3214  clojure.core/eval
                  core.clj: 3210  clojure.core/eval
                  main.clj:  437  clojure.main/repl/read-eval-print/fn
                  main.clj:  437  clojure.main/repl/read-eval-print
                  main.clj:  458  clojure.main/repl/fn
                  main.clj:  458  clojure.main/repl
                  main.clj:  368  clojure.main/repl
               RestFn.java: 1523  clojure.lang.RestFn/invoke
    interruptible_eval.clj:   79  nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj:   55  nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj:  142  nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
                  AFn.java:   22  clojure.lang.AFn/run
               session.clj:  171  nrepl.middleware.session/session-exec/main-loop/fn
               session.clj:  170  nrepl.middleware.session/session-exec/main-loop
                  AFn.java:   22  clojure.lang.AFn/run
               Thread.java:  835  java.lang.Thread/run

编辑:我已经在另一台计算机上尝试过此脚本,并且可以正常工作。我的计算机肯定有问题。

2 个答案:

答案 0 :(得分:2)

英特尔 MKL 错误代码 -1140 是 VSL_RNG_ERROR_ARS5_NOT_SUPPORTED。

您可以通过搜索安装中的头文件来查找错误代码。在我的 macOS 计算机上是这个文件:/opt/intel/oneapi/mkl/2021.1.1/include/mkl_vsl_defines.h

答案 1 :(得分:0)

ARS-5 仅在具有 AES-NI instructions 的微架构上可用,如果应用程序将在不支持 AES-NI 指令的微架构上启动,则 VSL RNG 例程将返回 VSL_RNG_ERROR_ARS5_NOT_SUPPORTED 状态代码。< /p>