Clorch is distributed as a git dependency and pulls its native PyTorch binaries through JavaCPP. There is no separate native install step for CPU usage — the JVM downloads and caches the right platform binaries on the first run. GPU support requires additional system packages and a compatible NVIDIA driver, which are covered below.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/antlobach/clorch/llms.txt
Use this file to discover all available pages before exploring further.
Create a Clojure project directory and add the following
deps.edn. The git coordinates pin Clorch to the v0.2.0 release:{:paths ["src"]
:deps {io.github.antlobach/clorch
{:git/tag "v0.2.0"
:git/sha "07642acdbc522e8aa2a20cd223912247614d2239"}}}
Clorch is tested across a full Java 21–25 matrix. Confirm your environment matches the supported stack before starting:
1.12.5.1664)2.10.0-1.5.13Java 24 and 25 require the
--enable-native-access=ALL-UNNAMED JVM flag for JavaCPP to load native libraries. Without it, the JVM may refuse to load the LibTorch bindings. See the REPL startup steps below for how to set this flag automatically.Setting
JAVA_TOOL_OPTIONS in your shell profile is the most convenient approach if you use Java 24+ regularly:Clorch detects the backend automatically when
clorch.torch loads. It uses CUDA when GPU natives are available and NVIDIA hardware is detected; otherwise it loads the CPU backend.CLORCH_FORCE_CPU=1CLORCH_FORCE_GPU=1GPU support requires Java 25, CUDA 13.1, cuDNN 9.19, and NCCL 2.29.2. The validated hardware is 2× RTX A5000 on a Linux host.
Set native-loading variables before the JVM starts.
JAVA_TOOL_OPTIONS is inherited by launcher-created worker JVMs, which is important for distributed training:export CLORCH_FORCE_GPU=1
export LD_LIBRARY_PATH="/usr/local/cuda/lib64:${LD_LIBRARY_PATH:-}"
export JAVA_TOOL_OPTIONS="--enable-native-access=ALL-UNNAMED"
CLOJURE_DISABLE_RLWRAP=1 clojure -M:dev
Multi-GPU Requirements
Distributed training uses one worker JVM per GPU and NCCL for inter-process communication. The full validated stack for multi-GPU work is:- Two or more NVIDIA GPUs visible to the same Linux host
- A working NVIDIA driver with CUDA 13 support
- One distinct CUDA device per rank
- Enough host RAM and CUDA VRAM for one model replica per rank
- A writable checkpoint directory and an available local TCP port
nREPL Dev Server
The repository’sdeps.edn includes a :dev alias that starts an nREPL server. Clone the repository and run:
127.0.0.1:7891 by default. Override the port or bind address with environment variables:
| Variable | Default | Effect |
|---|---|---|
CLORCH_NREPL_PORT | 7891 | Port the nREPL server binds to |
CLORCH_NREPL_BIND | 127.0.0.1 | Interface address the server listens on |