Nvidia support on NixOS
 
 
 

Having lots and lots of trouble with pip and nixos. It seems immutable filesystem that Nix prefers is not something that python people anticipated. Errors attempting to write modules into expected places via pip, even when running sudo, means that I’m unable to use a lot of examples I’m finding. So, I wanted to investigate whether I could get stuff running on the GPU but inside an isolated docker container.

Add this to configuration.nix.

  virtualisation.docker.enable = true;  
  hardware.opengl.driSupport32Bit = true;  
  virtualisation.docker.enableNvidia = true;  
  systemd.enableUnifiedCgroupHierarchy = false;

Then, nixos-rebuild switch, and reboot.

Then, this works! I’m excited to see what I can do now with all these fun packages but not be blocked by pip issues.

sudo docker run --rm --gpus all nvidia/cuda:11.4.0-base-ubuntu20.04 nvidia-smi  
[sudo] password for xrdawson:  
Tue Oct 11 15:23:01 2022        
+-----------------------------------------------------------------------------+  
| NVIDIA-SMI 470.63.01    Driver Version: 470.63.01    CUDA Version: 11.4     |  
|-------------------------------+----------------------+----------------------+  
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |  
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |  
|                               |                      |               MIG M. |  
|===============================+======================+======================|  
|   0  NVIDIA GeForce ...  Off  | 00000000:01:00.0  On |                  N/A |  
|  0%   39C    P8     7W / 120W |     39MiB /  6075MiB |      0%      Default |  
|                               |                      |                  N/A |  
+-------------------------------+----------------------+----------------------+  
                                                                                 
+-----------------------------------------------------------------------------+  
| Processes:                                                                  |  
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |  
|        ID   ID                                                   Usage      |  
|=============================================================================|  
+-----------------------------------------------------------------------------+  

Sadly, it looks like that version of the CUDA driver is outdated, so even this isn’t fully working for many examples. But, at least I’m getting closer.