Tensorflow: Difference between revisions

From NixOS Wiki
Updated wiki page on tensorflow. Old configuration didn't work anymore, so I provided one that worked for me
Klinger (talk | contribs)
m added Category:Python, link, description
 
Line 1: Line 1:
[https://www.tensorflow.org/ TensorFlow] is a free and open-source software library for machine learning and artificial intelligence.
= Tensorflow =
= Tensorflow =


Line 27: Line 28:
== References ==
== References ==
<ref name=":0" />
<ref name=":0" />
[[Category:Python]]

Latest revision as of 18:07, 25 August 2024

TensorFlow is a free and open-source software library for machine learning and artificial intelligence.

Tensorflow

Quick shell [1]

nix-shell --arg config '{ cudaSupport = true; allowUnfree = true; }' -p 'python3.withPackages (ps: [ ps.tensorflow ])'

This starts a shell with tensorflow and it has GPU support.

Shell config

A basic shell config would look something like this:

# shell.nix
{ pkgs ? import <nixpkgs> {}, config ? {} }:
let
  pythonPackages = pkgs.python3.withPackages (ps: [ ps.tensorflow ]);
in
pkgs.mkShell {
  name = "tf";
  buildInputs = [
    (pythonPackages)
  ];
  shellHook = ''
    export PYTHONPATH="${pythonPackages}:${PYTHONPATH:-}"
  '';
}

To make this configuration work, edit ~/.config/nxpkgs/config.nix:

# ~/.config/nxpkgs/config.nix
{ cudaSupport = true; allowUnfree = true;  }

References

[1]