Skip to content

Commit e8c07e2

Browse files
committed
Add pytorch-lightning from unstable while keeping torch-bin from stable.
1 parent b5f5178 commit e8c07e2

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

nix/dependencies.nix

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{ pkgs ? import <nixpkgs> {
2+
overlays = [
3+
(import ./overlay/replace-torch.nix { })
4+
];
25
config = {
36
allowUnfree = true;
47
cudaSupport = true;
@@ -7,9 +10,21 @@
710
, lib ? pkgs.lib
811
, my_python ? pkgs.python3
912
, cudatoolkit ? pkgs.cudaPackages.cudatoolkit
10-
, }:
13+
, unstable_pkgs ? import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz") {
14+
overlays = [
15+
(import ./overlay/replace-torch.nix {
16+
do_replace = true;
17+
replacement_torch = my_python.pkgs.torch;
18+
replacement_torchvision = my_python.pkgs.torchvision;
19+
replacement_torchaudio = my_python.pkgs.torchaudio;
20+
replacement_python = my_python;
21+
})
22+
];
23+
}
24+
}:
1125
let
1226
python_packages = my_python.pkgs;
27+
unstable_python_packages = unstable_pkgs.my_python.pkgs;
1328
in {
1429
pkgs = pkgs;
1530
lib = lib;
@@ -18,6 +33,7 @@ in {
1833
dependencies = with pkgs; [
1934
python_packages.numpy
2035
python_packages.torch-bin
36+
unstable_python_packages.pytorch-lightning
2137
cudatoolkit
2238
];
2339
}

nix/overlay/replace-torch.nix

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{ do_replace ? false
2+
, replacement_torch ? false
3+
, replacement_torchvision ? false
4+
, replacement_torchaudio ? false
5+
, replacement_python ? false }:
6+
final: prev:
7+
let
8+
real_python = if do_replace then replacement_python else prev.python311;
9+
real_torch = if do_replace then replacement_torch else real_python.pkgs.torch-bin;
10+
real_torchvision = if do_replace then replacement_torchvision else real_python.pkgs.torchvision-bin;
11+
real_torchaudio = if do_replace then replacement_torchaudio else real_python.pkgs.torchaudio-bin;
12+
real_python311 = real_python.override {
13+
packageOverrides = final_: prev_: {
14+
torch = real_torch;
15+
torchvision = real_torchvision;
16+
torchaudio = real_torchaudio;
17+
pytorch-lightning = prev_.pytorch-lightning.override {
18+
torch = real_torch;
19+
};
20+
tensorboardx = prev_.tensorboardx.override {
21+
torch = real_torch;
22+
};
23+
};
24+
};
25+
in {
26+
python311 = real_python311;
27+
my_python = real_python311;
28+
}

0 commit comments

Comments
 (0)