-
Notifications
You must be signed in to change notification settings - Fork 217
docs: add a Getting Started Section #1577
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
Changes from 1 commit
20c9ac0
ba529c6
0a97e25
22aab8f
ffe8caf
f252073
de77fd0
8955ff2
6f3b58e
dacb96f
b192288
162d60b
d5518fd
6cc84d1
6c33108
b397939
16f07f9
a48f578
a57c065
f4cedfd
5e8abee
2eef046
2129801
7905414
2a7df18
f4c2e66
28fb432
fb879b5
b8f794e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,186 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Installation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| The only prerequisite for installing Nx is Elixir itself. If you don´t have Elixir installed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| in your machine you can visit this [intallation page](https://elixir-lang.org/install.html). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| There are several ways to install Nx (Numerical Elixir), depending on your project type and needs. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ## Using Mix in a standardElixir Project | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| If you are working inside a Mix project, the recommended way to install Nx is by adding it to your mix.exs dependencies: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1. Open mix.exs and modify the deps function: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ```elixir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| defp deps do | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {:nx, "~> 0.5"} # Install the latest stable version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| end | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2. Fetch the dependencies, run on the terminal: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ```sh | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mix deps.get | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ## Installing Nx from GitHub (Latest Development Version) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| If you need the latest, unreleased features, install Nx directly from the GitHub repository. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1. Modify mix.exs: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ```elixir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| defp deps do | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {:nx, github: "elixir-nx/nx", branch: "main"} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {:nx, github: "elixir-nx/nx", branch: "main"} | |
| {:nx, github: "elixir-nx/nx", branch: "main", sparse: "nx"} |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| If you don’t have a Mix project and just want to run a standalone script, use Mix.install/1 to dynamically fetch and install Nx. | |
| If you don’t have a Mix project and just want to run a standalone script, use `Mix.install/1` to dynamically fetch and install Nx. |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| IO.inspect(tensor) | |
| IO.inspect(tensor) |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| {:nx, github: "elixir-nx/nx", branch: "main"} | |
| {:nx, github: "elixir-nx/nx", branch: "main", sparse: "nx"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Best for: Running Nx on GPUs or TPUs using Google’s XLA compiler. | |
| ## Installing Nx with Torchx for PyTorch Acceleration | |
| To run Nx operations on PyTorch’s backend (LibTorch): | |
| 1. Modify mix.exs: | |
| ```elixir | |
| defp deps do | |
| [ | |
| {:nx, "~> 0.5"}, | |
| {:torchx, "~> 0.5"} # PyTorch Backend | |
| ] | |
| end | |
| ``` |
Let's not mention Torchx. We could maybe reference EMLX, but it's not even released yet, so let's leave this for later.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 2. Fetch dependencies: | |
| ```sh | |
| mix deps.get | |
| ``` | |
| 3. Run with EXLA enabled: | |
| ```elixir | |
| Torchx.set_preferred_backend() | |
| ``` | |
| Best for: Deep learning applications with PyTorch acceleration. | |
| ## Installing Nx with OpenBLAS for CPU Optimization | |
| To optimize CPU performance with OpenBLAS: | |
| 1. Install OpenBLAS (libopenblas): | |
| - Ubuntu/Debian: | |
| ```sh | |
| sudo apt install libopenblas-dev | |
| ``` | |
| - MacOS (using Homebrew): | |
| ```sh | |
| brew install openblas | |
| ``` | |
| 2. Modify mix.exs: | |
| ```elixir | |
| defp deps do | |
| [ | |
| {:nx, "~> 0.5"}, | |
| {:openblas, "~> 0.5"} # CPU-optimized BLAS backend | |
| ] | |
| end | |
| ``` | |
| 3. Fetch dependencies: | |
| ```sh | |
| mix deps.get | |
| ``` | |
| Best for: Optimizing CPU-based tensor computations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.