Skip to content

Commit

Permalink
edm.gpuChecks.example: init
Browse files Browse the repository at this point in the history
  • Loading branch information
SomeoneSerge committed Dec 20, 2023
1 parent 628b080 commit e49b718
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions python-packages/by-name/ed/edm/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
, python
, singularity-tools
, nixglhost
, runCommand
}:

buildPythonPackage rec {
Expand Down Expand Up @@ -87,6 +88,46 @@ buildPythonPackage rec {
(python.withPackages (_: [ edm ]))
];
};
passthru.dnnlibCache = runCommand "edm-dnnlib-cache"
{
nativeBuildInputs = [ edm.pythonWith ];
outputHashMode = "recursive";
outputHashAlgo = "sha256";
outputHash = "sha256-xzG8f40BVvjVFH2MlNX9TNoKOEDSNJ8nYidtiC3mV0o=";
env.urls = builtins.concatStringsSep "\n"
(map (x: "https://nvlabs-fi-cdn.nvidia.com/edm/pretrained/${x}") [
"edm-cifar10-32x32-cond-vp.pkl"
"edm-ffhq-64x64-uncond-vp.pkl"
"edm-afhqv2-64x64-uncond-vp.pkl"
"edm-imagenet-64x64-cond-adm.pkl"
]);
}
''
export HOME=$out
python << EOF
import os
import edm.dnnlib as dnnlib
for url in os.environ["urls"].split():
with dnnlib.util.open_url(url) as f:
pass
EOF
'';
passthru.gpuChecks.example = runCommand "edm-samples"
{
nativeBuildInputs = [ edm.pythonWith ];

# Cf. https://github.com/NixOS/nixpkgs/pull/256230
requiredSystemFeatures = [ "cuda" ];
}
''
set -e
mkdir tmp
cd tmp
HOME="${edm.dnnlibCache}" python -m edm.example
cd ..
cp -r tmp/ $out
'';

meta = with lib; {
description = "Elucidating the Design Space of Diffusion-Based Generative Models (EDM)";
Expand Down

0 comments on commit e49b718

Please sign in to comment.