uncomplicate / deep-diamond

A fast Clojure Tensor & Deep Learning library
https://aiprobook.com
Eclipse Public License 1.0
432 stars 17 forks source link

clCreateCommandQueueWithProperties is not supported #6

Closed zendevil closed 3 years ago

zendevil commented 3 years ago

I'm using the opencl factory to create a tensor like so:

(opencl/with-default
  (with-release
    [opencl-factory (opencl-float *context* *command-queue*)]
    (tensor opencl-factory
            (desc [2 3 2]))))

But I'm getting the following error:

   The function clCreateCommandQueueWithProperties is not supported

                   CL.java:   -2  org.jocl.CL/clCreateCommandQueueWithPropertiesNative
                   CL.java: 5388  org.jocl.CL/clCreateCommandQueueWithProperties
                  impl.clj:  510  uncomplicate.clojurecl.internal.impl/command-queue*
                  impl.clj:   -1  uncomplicate.clojurecl.internal.impl/command-queue*
                  core.clj:  879  uncomplicate.clojurecl.core/command-queue
                  core.clj:  837  uncomplicate.clojurecl.core/command-queue
                  core.clj:  881  uncomplicate.clojurecl.core/command-queue
                  core.clj:  837  uncomplicate.clojurecl.core/command-queue
                      REPL:   60  clotorch.flight.core/eval119139
                      REPL:   60  clotorch.flight.core/eval119139
             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:  137  clojure.lang.RestFn/applyTo
                  core.clj:  665  clojure.core/apply
                  core.clj:  660  clojure.core/apply
                regrow.clj:   18  refactor-nrepl.ns.slam.hound.regrow/wrap-clojure-repl/fn
               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:  748  java.lang.Thread/run

How to fix this error?

blueberry commented 3 years ago

opencl-factory is not a Deep Diamond factory. I guess that if you implemented it, you should make it extend DD protocols. If it's Neanderthal's factory, it can create Neanderthal artifacts, so it's used at the wrong place.

zendevil commented 3 years ago

Can you please tell me what the code will look like for creating a tensor using native factory?

taijiren commented 3 years ago

This worked for me...

(ns foo
  (:require
    [uncomplicate.diamond.tensor :refer [tensor shape data-type layout]]
    [uncomplicate.diamond.native]))

(def t1 (tensor 3))
(shape t1)
(data-type t1)
(layout t1)
zendevil commented 3 years ago

This doesn't work for me completely.

Evaluating t1 or (tensor 3) gives NullPointerException.

Here's the full stack trace:

1. Caused by java.lang.NullPointerException
   (No message)

              Numbers.java: 1068  clojure.lang.Numbers/ops
              Numbers.java:  121  clojure.lang.Numbers/isPos
                  core.clj: 2884  clojure.core/take/fn
              LazySeq.java:   42  clojure.lang.LazySeq/sval
              LazySeq.java:   51  clojure.lang.LazySeq/seq
                   RT.java:  535  clojure.lang.RT/seq
                  core.clj:  137  clojure.core/seq
                  core.clj: 3133  clojure.core/dorun
                  core.clj: 3148  clojure.core/doall
                  core.clj: 3148  clojure.core/doall
                tensor.clj:  507  uncomplicate.diamond.internal.dnnl.tensor/eval76732/fn
              MultiFn.java:  234  clojure.lang.MultiFn/invoke
                pprint.clj:   40  cider.nrepl.pprint/pr/fn
                  AFn.java:  152  clojure.lang.AFn/applyToHelper
                  AFn.java:  144  clojure.lang.AFn/applyTo
                  core.clj:  665  clojure.core/apply
                  core.clj: 1973  clojure.core/with-bindings*
                  core.clj: 1973  clojure.core/with-bindings*
               RestFn.java:  425  clojure.lang.RestFn/invoke
                pprint.clj:   37  cider.nrepl.pprint/pr
                pprint.clj:   29  cider.nrepl.pprint/pr
                  Var.java:  393  clojure.lang.Var/invoke
                 print.clj:  224  nrepl.middleware.print/wrap-print/fn/print
                 print.clj:  148  nrepl.middleware.print/send-nonstreamed/print-key/fn
                 print.clj:  147  nrepl.middleware.print/send-nonstreamed/print-key
                  core.clj: 2742  clojure.core/map/fn/fn
             protocols.clj:   49  clojure.core.protocols/iter-reduce
             protocols.clj:   75  clojure.core.protocols/fn
             protocols.clj:   75  clojure.core.protocols/fn
             protocols.clj:   13  clojure.core.protocols/fn/G
                  core.clj: 6884  clojure.core/transduce
                  core.clj: 6870  clojure.core/transduce
                 print.clj:  156  nrepl.middleware.print/send-nonstreamed
                 print.clj:  138  nrepl.middleware.print/send-nonstreamed
                 print.clj:  174  nrepl.middleware.print/printing-transport/reify
                caught.clj:   58  nrepl.middleware.caught/caught-transport/reify
           track_state.clj:  228  cider.nrepl.middleware.track-state/make-transport/reify
    interruptible_eval.clj:  114  nrepl.middleware.interruptible-eval/evaluate/fn
                  main.clj:  442  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:  137  clojure.lang.RestFn/applyTo
                  core.clj:  665  clojure.core/apply
                  core.clj:  660  clojure.core/apply
                regrow.clj:   18  refactor-nrepl.ns.slam.hound.regrow/wrap-clojure-repl/fn
               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:  748  java.lang.Thread/run