# Ruby to PyTorch: test the process boundary before CUDA — executable example

Six Ruby integration tests (13 assertions) and three Python tests passed with real CPU PyTorch. CUDA execution was not available.

Environment: Python3.11.5; macOS14.5 arm64; Ruby3.3.2; Minitest6.0.6; torch2.9.1; numpy2.2.6; CPU.

Keep these files together: client.rb, test_client.rb, test_worker.py, worker.py. Download all at [/assets/examples/archive-harnessing-nvidias-cuda-power-with-ruby-for-enhanced-computing-performance/example.zip](https://oneruby.dev/assets/examples/archive-harnessing-nvidias-cuda-power-with-ruby-for-enhanced-computing-performance/example.zip).

## Run

The recorded commands used the interpreter paths shown below. On your computer use Ruby and Python with the recorded versions and dependencies. The Ruby bridge reads PYTHON for its Python interpreter; set it to your PyTorch environment.

```sh
/Users/alexandrkholodniak/anaconda3/bin/python3 -B -m unittest -v test_worker.py
/Users/alexandrkholodniak/.rvm/rubies/ruby-3.3.2/bin/ruby test_client.rb --seed 42
/Users/alexandrkholodniak/.rvm/rubies/ruby-3.3.2/bin/ruby client.rb
```


Direct dependency versions are recorded in requirements.txt. The existing installed environment was executed; a fresh dependency installation was not rerun.

## Limits

- Actual local CPU subprocess integration, no CUDA device execution or performance comparison.
- One process per request; trusted worker, no process deadline or worker pool.
- Existing exact dependency environment tested; fresh environment installation not validated.
