MXNet Clojure Environment

1.
Setup

Clojure deps.edn file, which will be mounted into the filesystem when the runtime boots—this installs MXNet and the Clojure frontend. Note that the current version of Clojure/MXNet is compiled against CUDA 9.0, so we must set NEXTJOURNAL_MOUNT_CUDA appropriately in the runtime config.

{ :deps {
  org.apache.mxnet.contrib.clojure/clojure-mxnet-linux-gpu {
    :mvn/version "1.3.1" },
  nu.pattern/opencv {:mvn/version "2.4.9-7"},
  net.mikera/imagez {:mvn/version "0.12.0"},
  thinktopic/think.image {:mvn/version "0.4.16"}}}
deps.edn
Extensible Data Notation

Install various dependencies, including Scala and OpenCV.

(clojure-version)
"1.10.0"
apt-get -qq update
apt-get install --no-install-recommends software-properties-common \
  runit apt-transport-https build-essential devscripts \
  libopenblas-base libatlas3-base \
  libcurl3 scala libssl1.0.0 \
  libgdal20 libilmbase12 libopenexr22 libtbb2 libwebp6
add-apt-repository -y ppa:timsc/opencv-3.4
apt-get -qq update
apt-get install libopencv-imgcodecs3.4
apt-get clean

ldconfig
(require '[org.apache.clojure-mxnet.ndarray :as ndarray]
         '[org.apache.clojure-mxnet.context :as context])
(ndarray/->vec (ndarray/+ 
 (ndarray/ones [3 3] {:ctx (context/gpu 0)}) 
 (ndarray/ones [3 3] {:ctx (context/gpu 0)}))