An Nx
backend for candle (docs, repo, crate) machine learning framework
If available in Hex, the package can be installed
by adding candlex
to your list of dependencies in mix.exs
:
def deps do
[
{:candlex, "~> 0.1.10"}
]
end
Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/candlex.
Just configure Nx to default to Candlex backend in your configuration:
# Possibly config/runtime.exs
config :nx, default_backend: Candlex.Backend
or in your scripts, precede all your Nx operations with:
Nx.default_backend(Candlex.Backend)
More details in Nx backends
Defaults to false
. If true
the native binary is built locally, which may be useful
if no precompiled binary is available for your target environment. Once set, you
must run mix deps.clean candlex --build
explicitly to force to recompile.
Building has a number of dependencies, see Building from source below.
The default value is cpu
, which implies the final the binary supports targeting
only the host CPU.
Value | Target environment |
---|---|
cpu | |
cuda | CUDA 12.x |
To use Candlex with NVidia GPU you need CUDA compatible with your GPU drivers.
To build the native binary locally you need to set CANDLEX_NIF_BUILD=true
.
Keep in mind that the compilation usually takes time.
You will need the following installed in your system for the compilation:
To build native binary with GPU support, you need to run in an environment that has CUDA installed,
then you can build with CANDLEX_NIF_TARGET=cuda
. See the CANDLEX_NIF_TARGET
for more details.
To publish a new version of this package:
- Update version in
mix.exs
,.github/workflows/binaries.yml
andREADME.md
. git commit -am "build: bump version to <tag-version>"
git tag -s <tag-version>
to create new signed tag.git push origin <tag-version>
to push the tag.- Wait for the
binaries.yml
GitHub workflow to build all the NIF binaries. - Publish the newly created draft release in GitHub (the download won't find the binaries otherwise).
mix rustler_precompiled.download Candlex.Native --all --print
to generate binaries checksums locally.rm -r native/candlex/target priv/native
to leave out rust crate build artifacts from published elixir package.mix hex.build --unpack
to check the package includes the correct files.mix hex.publish
to publish package to Hex.pm.git push origin main
Copyright 2023 Mimiquate
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.