29 Oct 2022 |
| Tseb joined the room. | 06:12:40 |
31 Oct 2022 |
| underpantsgnome changed their display name from underpantsgnome! to underpantsgnome. | 20:24:47 |
4 Nov 2022 |
hacobjinkle | In reply to@carlthome:matrix.org
I'm trying to get TensorFlow to work with a NVIDIA GPU on Ubuntu 22.04 LTS by a shell.nix but get caught up on missing library imports upon import tensorflow as tf .
I have the Ubuntu provided NVIDIA Display Driver installed and libnvidia-container works with GPU but I'm trying to nix:ify my life more and more without plunging into NixOS.
Does anyone have a working shell.nix for GPU-accelerated PyTorch/TensorFlow/JAX on a Debian-based distro?
{
description = "PyTorch code for deep learning on chest X-rays (CXR)";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-22.05";
flake-utils.url = "github:numtide/flake-utils";
};
# See https://old.reddit.com/r/Python/comments/npu66t/reproducible_python_environment_with_nix_flake/
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachSystem [ "x86_64-linux" ] (system:
let
python = "python310";
pkgs = (import nixpkgs {
inherit system;
config = {
allowUnfree = true;
cudaSupport = true;
};
overlays = [
];
});
# core pkgs are those required to run headless scripts
corePythonPkgs = ps: with ps; [
numpy
pandas
pytorchWithCuda
scikit-learn
scipy
#torchinfo # currently does not build on nix 22.05?? as of 2022-09-29
torchvision
tqdm
];
corePythonEnv = pkgs.${python}.withPackages corePythonPkgs;
jupyterPythonEnv = pkgs.${python}.withPackages (ps: with ps;
((corePythonPkgs ps) ++ [
ipympl # for %matplotlib widget
jupyterlab
matplotlib
# not strictly for jupyter but still useful for development
black
]));
in rec {
packages = {
download = pkgs.stdenv.mkDerivation {
name = "download";
propagatedBuildInputs = with pkgs; [
google-cloud-sdk
./download_mimic_cxr_jpg.sh
];
};
};
apps = rec {
default = jupyter;
jupyter = {
type = "app";
# Note that this is not a full command line; do not include
# arguments. If you would like to provide a command line, see the
# "foo" example further down in this file
program = "${jupyterPythonEnv}/bin/jupyter";
};
download = with pkgs; {
type = "app";
program = "${packages.download}/download_mimic_cxr_jpg.sh";
};
};
devShell = pkgs.mkShell { buildInputs = with pkgs; [ jupyterPythonEnv ]; };
});
} | 13:27:35 |
hacobjinkle | I run that on Ubuntu 20.04 workstation | 13:27:55 |
hacobjinkle | note that you need to use nixGL | 13:28:09 |
hacobjinkle | I don't reference nixGL in my flake.nix. Instead, I use nix run or nix develop , prefixed with nixGL | 13:28:33 |
hacobjinkle | nixgl can be built with a command like the following NIXPKGS_ALLOW_UNFREE=1 nix build --impure github:guibou/nixgl#nixGLNvidia -o nixgl | 13:30:10 |
hacobjinkle | in my case that results in a file nixgl/bin/nixGLNvidia-515.65.01 | 13:30:51 |
hacobjinkle | have to rerun the command above whenever you update your nvidia driver | 13:31:13 |
hacobjinkle | so for example. you can run nix develop then `$ nixGLNvidia python -c "import torch; print(torch.cuda.is_available())" True ` | 13:35:13 |
hacobjinkle | * so for example. you can run nix develop then `$ nixGLNvidia python -c "import torch; print(torch.cuda.is_available())" True` | 13:35:19 |
hacobjinkle | * so for example. you can run nix develop then ``` $ nixGLNvidia python -c "import torch; print(torch.cuda.is_available())" True ``` | 13:35:33 |
hacobjinkle | * so for example. you can run nix develop then \$ nixGLNvidia python -c "import torch; print(torch.cuda.is\_available())"
True | 13:35:49 |
hacobjinkle | * so for example. you can run nix develop then $ nixGLNvidia-515.65.01 python -c "import torch; print(torch.cuda.is\_available())"
True | 13:36:07 |
hacobjinkle | * so for example. you can run nix develop then $ nixGLNvidia-515.65.01 python -c "import torch; print(torch.cuda.is_available())"
True | 13:36:20 |
hacobjinkle | also note it's probably better to pin the nixpkgs version using the flake.lock only, instead of calling out a tag like I did there with nixos-22.05 . I'm still figuring this stuff out | 13:37:23 |
6 Nov 2022 |
| spott joined the room. | 18:26:21 |
8 Nov 2022 |
| pbsds changed their profile picture. | 00:46:23 |
10 Nov 2022 |
| Leix b joined the room. | 16:10:16 |
11 Nov 2022 |
| bbenno joined the room. | 02:10:42 |
| evils left the room. | 21:52:39 |
13 Nov 2022 |
| Herman joined the room. | 19:54:42 |
14 Nov 2022 |
| lgnus joined the room. | 12:37:20 |
15 Nov 2022 |
| spott changed their display name from Andrew Spott to spott. | 03:30:47 |
| seapat joined the room. | 17:52:49 |
| Carl Thomé changed their display name from carlthome to Carl Thomé. | 23:41:26 |
| Carl Thomé set a profile picture. | 23:41:46 |
16 Nov 2022 |
| omlet joined the room. | 20:34:26 |
19 Nov 2022 |
| edrex joined the room. | 00:44:51 |
20 Nov 2022 |
| benjaminedwardwebb joined the room. | 01:59:45 |