Without nix, I can get pytorch to use cuda if I install using pip. But if I use nix and the pytorch-bin
package:
{ pkgs ? import <nixpkgs>
{
config =
{
allowUnfree = true;
cudaSupport = true;
};
}
}:
pkgs.mkShell {
buildInputs =
[
pkgs.python38
#pkgs.python38Packages.pytorch
pkgs.python38Packages.pytorch-bin
];
}
I get the following error
torch.cuda.current_device()
Traceback (most recent call last):
File “”, line 1, in
File “/nix/store/az7dskqa2whs3dwihr1g9n9zmafs4dd8-python3.8-pytorch-1.8.1/lib/python3.8/site-packages/torch/cuda/init.py”, line 388, in current_device
_lazy_init()
File “/nix/store/az7dskqa2whs3dwihr1g9n9zmafs4dd8-python3.8-pytorch-1.8.1/lib/python3.8/site-packages/torch/cuda/init.py”, line 170, in _lazy_init
torch._C._cuda_init()
RuntimeError: Found no NVIDIA driver on your system. Please check that you have an NVIDIA GPU and installed a driver from Download The Latest Official NVIDIA Drivers
Since this is a run time error, I imagined that an environment variable was being lost in nix-shell, but by comparing the outputs of printenv, nix seems to only append to the current environment variables.
I also tried the plain pytorch nix-package, but the build becomes non-responsive when building magma-2.5.4
[54/3311] Building Fortran object CMakeFiles/lapacktest.dir/testing/lin/chet21.f.o
…/testing/lin/chet21.f:311:33:309 | DO 20 J = 1, N - 1
| 2
310 | CALL CHER2( CUPLO, N, -CMPLX( E( J ) ), U( 1, J ), 1,
311 | $ U( 1, J-1 ), 1, WORK, N )
| 1
Warning: Array reference at (1) out of bounds (0 < 1) in loop beginning at (2)