
A shell for GPU computing
Work in a full Nushell-based shell, from everyday file commands and structured pipelines to native GPU tensors and neural networks. Powered by LibTorch on Metal for Apple-silicon macOS.
Inside NuTorch
use torch
let a = (torch tensor [1 2 3])
let b = (torch tensor [4 5 6])
torch add $a $b | torch value
# [5.0, 7.0, 9.0] — GPU computation, returned as a listAvailable through Homebrew for Apple silicon on macOS Tahoe 26.x. The native shell and LibTorch are included.
Install NuTorch with Homebrew
On an Apple-silicon Mac running macOS Tahoe 26.x, install Homebrew if needed, then run these commands in your terminal. The package includes NuTorch and LibTorch, ready to use.
brew trust astrohackerlabs/astrohacker
brew tap astrohackerlabs/astrohacker
brew install nutorchThen launch NuTorch:
nutorchAt the new NuTorch prompt, type use torch to enable the native tensor commands shown above. Ordinary shell commands work immediately, without this import. Each standalone tensor example includes its own import so you can run it in a fresh session.
Shell-native tensors
Each command calls the native tensor core in the shell process. Results are shared values, so tensor operations compose naturally in structured pipelines.
Follow the NuTorch setup instructions to launch the installed shell, then enter use torch.
Matrix multiplication inside NuTorch
use torch
let t = ([[1 2] [3 4]] | torch tensor)
$t | torch mm $t | torch value
# [[7.0, 10.0], [15.0, 22.0]]Autograd
use torch
let w = torch tensor [1 2 3] --requires_grad
let loss = (torch mul $w $w | torch sum)
torch backward $loss
torch grad $w | torch value
# [2.0, 4.0, 6.0]Apple-silicon GPU
NuTorch runs tensors on Metal through LibTorch. There is no CPU mode and no device flag.
A full Nushell shell
Use structured pipelines, records, lists, functions and scripts. Import the native tensor commands with use torch.
PyTorch-style API
Operation names, arguments, defaults, broadcasting, autograd, modules, and optimizers follow PyTorch wherever possible.
Native tensor ownership
The shell owns shared tensor, module and optimizer references. LibTorch manages GPU storage and the computation graph in the same process.