v2026.11.2
All Bundles
Bundle

Convolutional neural networks on the CPU: layers with forward and backward passes, the Adam and SGD optimizers, an image dataset with train, validation and test splits and on-the-fly augmentation, and a training loop that records the metrics of every epoch. The layers are native (libobjk_ml, Eigen plus a small thread pool); this library holds the model API, the dataset and the trainer. Compile with -lib ml_cnn,ml,ml_lab,opencv,csv,json,cipher,gen_collect. Design, validation and measurements: docs/AI.md, "Convolutional networks (System.ML.Cnn)".

CnnRuntime

Process-wide settings of the native layers and a seeded shuffle.

Operations

CudaDeviceCount # function

How many CUDA devices the optional GPU library found. The library (libobjk_ml_cuda, built apart from Objeck, see docs/AI.md) is loaded on the first call; without it, or without an NVIDIA GPU and driver, the answer is 0 and CudaStatus() says why.

function : CudaDeviceCount() ~ Int

Return

TypeDescription
Intthe device count, 0 when CUDA is unavailable

CudaFreeMemory # function

The memory that is free on a CUDA device right now.

function : CudaFreeMemory(index:Int) ~ Int

Parameters

NameTypeDescription
indexIntdevice number

Return

TypeDescription
Intfree megabytes, 0 when there is no such device

CudaStatus # function

Why CUDA cannot be used.

function : CudaStatus() ~ String

Return

TypeDescription
Stringthe reason, or an empty string when a CUDA device is available

GetDevices # function

The devices a model can be placed on, as the names SetDevice takes: "cpu", then "cuda:0", "cuda:1" ... with the GPU's name and memory.

function : GetDevices() ~ String[]

Return

TypeDescription
Stringthe descriptions, "cpu" first

GetThreads # function

The number of threads the layers use.

function : GetThreads() ~ Int

Return

TypeDescription
Intthread count

HasCuda # function

Is there a CUDA device a model can run on?

function : HasCuda() ~ Bool

Return

TypeDescription
Booltrue if so

Permutation # function

A seeded shuffle of 0 .. n - 1 (Fisher-Yates), the same on every platform.

function : Permutation(n:Int, seed:Int) ~ Int[]

Parameters

NameTypeDescription
nInthow many values, 1 or more
seedIntshuffle seed

Return

TypeDescription
Intthe permutation, or Nil when n is below 1

SetThreads # function

Sets how many threads the layers use (the batch is spread over them, one sample per task). The setting is process-wide: every model, on every Objeck thread, shares the one pool. The default is the number of hardware threads, at most 8, which differs between machines; a run repeats bit for bit only at a fixed thread count, so set it (to 1 or any fixed number) for a result that must be the same on another machine.

function : SetThreads(count:Int) ~ Int

Parameters

NameTypeDescription
countIntthreads, 1 to 64

Return

TypeDescription
Intthe thread count now in force