NuTorch
The NuTorch logo: a green nautilus shell with a flame

GPU tensors from your shell

Run PyTorch-style tensor operations from bash, zsh, fish, or Nushell. NuTorch keeps tensors on the GPU and passes lightweight handles through ordinary shell pipelines. For macOS.

a=$(torch tensor '[1,2,3]')
b=$(torch tensor '[4,5,6]')
torch add $a $b | torch value
# [5.0,7.0,9.0]   computed on the GPU

Powered by LibTorch on Metal. Requires an Apple-silicon Mac.

Installation

Install with Homebrew. On supported Macs, Homebrew downloads a prebuilt bottle.

brew tap nutorch/nutorch
brew trust nutorch/nutorch   # brew 6.0+ requires trusting third-party taps
brew install nutorch

Shell-native tensors

Each command sends one operation to the daemon. Results come back as handles, so tensor operations compose naturally in pipelines.

bash

m=$(torch randn '[3,3]')
torch mm $m $m | torch mean | torch value
# matrix product, then mean — one pipeline

nushell

use nutorch.nu *
let t = ([[1 2] [3 4]] | torch tensor)
$t | torch mm $t | torch value
# native table out

Autograd

w=$(torch randn '[3]' --requires_grad)
loss=$(torch mul $w $w | torch sum)
torch backward $loss
torch grad $w | torch value

Apple-silicon GPU

NuTorch runs tensors on Metal through LibTorch. There is no CPU mode and no device flag.

Works in any shell

Handles are plain strings, so bash, zsh, fish, scripts, and pipelines all work naturally. Nushell gets structured commands too.

PyTorch-style API

Operation names, arguments, defaults, broadcasting, autograd, modules, and optimizers follow PyTorch wherever possible.

Daemon-backed tensors

A background daemon owns the tensors, GPU memory, and computation graph. Commands stay small; tensor data stays out of the shell.