Tensorflow: Difference between revisions
imported>Samuela No edit summary |
Sv-cheats-1 (talk | contribs) Updated wiki page on tensorflow. Old configuration didn't work anymore, so I provided one that worked for me |
||
Line 1: | Line 1: | ||
= Tensorflow = | = Tensorflow = | ||
== | === Quick shell <ref name=":0">https://discourse.nixos.org/t/cuda-tensorflow-my-setup-is-really-hacky-would-appreciate-help-unhackying-it/43912/2</ref> === | ||
nix-shell --arg config '{ cudaSupport = true; allowUnfree = true; }' -p 'python3.withPackages (ps: [ ps.tensorflow ]<code>)'</code> | |||
This starts a shell with tensorflow and it has GPU support. | |||
''' | === Shell config === | ||
A basic shell config would look something like this: | |||
<code># shell.nix | |||
{ pkgs ? import <nixpkgs> {}, config ? {} }: | |||
let | |||
<nowiki> </nowiki> pythonPackages = pkgs.python3.withPackages (ps: [ ps.tensorflow ]); | |||
in | |||
pkgs.mkShell { | |||
<nowiki> </nowiki> name = "tf"; | |||
<nowiki> </nowiki> buildInputs = [ | |||
<nowiki> </nowiki> (pythonPackages) | |||
<nowiki> </nowiki> ]; | |||
<nowiki> </nowiki> shellHook = <nowiki>''</nowiki> | |||
<nowiki> </nowiki> export PYTHONPATH="${pythonPackages}:${PYTHONPATH:-}" | |||
<nowiki> </nowiki> <nowiki>''</nowiki>; | |||
}</code> | |||
To make this configuration work, edit <code>~/.config/nxpkgs/config.nix</code>: | |||
<code># ~/.config/nxpkgs/config.nix | |||
{ cudaSupport = true; allowUnfree = true; }</code> | |||
== | == References == | ||
<ref name=":0" /> | |||
< | |||
Revision as of 11:24, 2 May 2024
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; }