Skip to content

Commit

Permalink
Compute $LD_LIBRARY_PATH from nix-gl-host
Browse files Browse the repository at this point in the history
- This PR removes $CUDA_HOME/lib from $LD_LIBRARY_PATH because bitsandbytes can follow PyTorch's CUDA runtime since bitsandbytes-foundation/bitsandbytes#1041, and setting $LD_LIBRARY_PATH for `bitsandbytes` is not necessary any more
- Hard-coded `/run/opengl-driver/lib` are removed because nix-gl-host can print the driver path for both Ubuntu and NixOS since numtide/nix-gl-host#16
- `link-nvidia-drivers.nix` is removed because drivers are instead copied to a cache directory by nix-gl-host
  • Loading branch information
Atry committed Aug 3, 2024
1 parent e30eb18 commit 4b95be7
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 65 deletions.
2 changes: 1 addition & 1 deletion examples/my-project/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
inputs.nix-ml-ops.flakeModules.kubernetesJob
inputs.nix-ml-ops.flakeModules.kubernetesService
inputs.nix-ml-ops.flakeModules.devcontainer
inputs.nix-ml-ops.flakeModules.linkNvidiaDrivers
inputs.nix-ml-ops.flakeModules.cuda
inputs.nix-ml-ops.flakeModules.volumeMountNfs
inputs.nix-ml-ops.flakeModules.devcontainerGcpCliTools
inputs.nix-ml-ops.flakeModules.gkeCredential
Expand Down
15 changes: 8 additions & 7 deletions flake-modules/cuda.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,25 @@ topLevel@{ flake-parts-lib, inputs, ... }: {
imports = [
inputs.flake-parts.flakeModules.flakeModules
./common.nix
./link-nvidia-drivers.nix
];
flake.flakeModules.cuda = {
imports = [
topLevel.config.flake.flakeModules.common
topLevel.config.flake.flakeModules.linkNvidiaDrivers
];
options.perSystem = flake-parts-lib.mkPerSystemOption ({ lib, pkgs, system, ... }: {
config = lib.mkIf (system != "aarch64-darwin") {
nixpkgs.config.allowUnfree = true;
nixpkgs.config.cudaSupport = true;

ml-ops.common = common: {
config.LD_LIBRARY_PATH = lib.mkMerge [
"/run/opengl-driver/lib"
# bitsandbytes need to search for CUDA libraries
"${common.config.environmentVariables.CUDA_HOME}/lib"
];
config.devenvShellModule.enterShell = ''
export LD_LIBRARY_PATH="$(${
lib.escapeShellArgs [
"${inputs.nix-gl-host.defaultPackage.${system}}/bin/nixglhost"
"--print-ld-library-path"
]
})":''${LD_LIBRARY_PATH:-}
'';
config.devenvShellModule.packages = [
common.config.cuda.home
];
Expand Down
57 changes: 0 additions & 57 deletions flake-modules/link-nvidia-drivers.nix

This file was deleted.

21 changes: 21 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@
inputs.nixpkgs.follows = "nixpkgs";
};
nix-ld-rs.url = "github:nix-community/nix-ld-rs";
nix-gl-host = {
url = "github:Atry/nix-gl-host";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs:
let
Expand Down

0 comments on commit 4b95be7

Please sign in to comment.