8000 Improve Linux install instructions by gose · Pull Request #57 · ankane/torch.rb · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Improve Linux install instructions #57

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 27 additions & 5 deletions README.md
CBFC
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,50 @@ Check out:

## Installation

First, [download LibTorch](https://pytorch.org/get-started/locally/). For Mac arm64, use:
First, download LibTorch by using their [configuration matrix](https://pytorch.org/get-started/locally/) to get the right URL for your platform.

For macOS arm64, you can use:

```sh
curl -L https://download.pytorch.org/libtorch/cpu/libtorch-macos-arm64-2.4.1.zip > libtorch.zip
unzip -q libtorch.zip
```

For Linux x86-64, use the `cxx11 ABI` version. For other platforms, build LibTorch from source.
For Linux x86-64, use their configuration matrix to select the platform choices that are right for you. If you want CUDA support, specify that in the Compute Platform section of their matrix along with Language: C++/Java. Download the version with `cxx11 ABI` in the URL.

For other platforms, build LibTorch from source. Windows is not currently supported.

Then run:
Once you have the LibTorch library downloaded, run:

```sh
bundle config build.torch-rb --with-torch-dir=/path/to/libtorch
```

And add this line to your application’s Gemfile:
Create a Gemfile and add this line to it:

```ruby
gem "torch-rb"
```

It can take 5-10 minutes to compile the extension. Windows is not currently supported.
Create a simple test program (e.g., "test.rb"):

```ruby
require 'torch-rb'

# Returns true on macOS
puts Torch::Backends::MPS.available?
# Returns truue on Linux with CUDA and an NVIDIA GPU installed
puts Torch::CUDA.available?
```

Install the gem and run your program:

```bash
bundle install
ruby test.rb
```

It can take 5-10 minutes to compile the extension.

## Getting Started

Expand Down
0