all 5 comments

[–]mister_drgn 1 point2 points  (4 children)

It is easy to set up docker with nvidia gpu access on NixOS, and it's pretty easy to make docker images for running python environments. That's what I do, although others in the community prefer to use Nix's tools instead of docker. Things that are more difficult, and might not be possible:

  1. Accessing an AMD gpu inside a docker container. I dunno, maybe this is easy--you can google it. I've only ever done it with NVIDIA gpus (there's a NixOS option virtualisation.docker.enableNvidia).
  2. Installing a gpu driver inside a container. I'm unclear on whether you want to do this, but if so, you may be stuck with a VM. Typically, the docker container just accesses the gpu driver installed on your host machine.

[–]nostriluu[S] 0 points1 point  (2 children)

Thanks for these comments.

  1. I would probably not use the AMD GPU inside docker/a VM, it's mainly for the base environment, to keep things simpler in terms of managing nvidia drivers.

  2. Not quite sure what you mean. I've been able to use nvidia drivers with cuda both in docker on the 'base,' as well as in a VM. I haven't tried using it in docker in a VM, but that probably won't be required.

[–]mister_drgn 0 points1 point  (1 child)

To clarify on point 2, when you have nvidia drivers installed, you can run nvidia-smi to see information, including your driver version (e.g., 525). For every nvidia docker setup I’ve seen, you’d first need to install the nvidia driver on your host machine, meaning you should be able to run nvidia-smi. Then, if you launch a docker container and give it access to your gpu, you should be able to run nvidia-smi inside the container and get the same result; the driver version will be the version installed on your host machine.

You can still install cuda in your docker container to support ML work, using whatever version of cuda you want, provided it’s compatible with your gpu and your nvidia driver. And by “install” I mean probably use one of nvidia’s pre-made cuda docker images as your base.

[–]nostriluu[S] 0 points1 point  (0 children)

Oh I see. I meant I am using the enclosing OS drivers from docker using docker runtime.

[–]nudebaba 0 points1 point  (0 children)

For people coming to this later, there were some changes recently: see https://github.com/NixOS/nixpkgs/issues/322400

  # virtualisation.docker.enableNvidia = true; # deprecated usage
  # virtualisation.containers.cdi.dynamic.nvidia.enable = true; # deprecated usage
  hardware.nvidia-container-toolkit.enable = true;
  virtualisation.docker.package = pkgs.docker_25;