Skip to content

Instantly share code, notes, and snippets.

@GaetanLepage
Created December 6, 2022 08:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GaetanLepage/2db5b319488c406c7c204c99fefca7e5 to your computer and use it in GitHub Desktop.
Save GaetanLepage/2db5b319488c406c7c204c99fefca7e5 to your computer and use it in GitHub Desktop.
Python environment
#!/bin/sh
use flake .#intel
source venv/bin/activate
{
description = "rlan nix flake";
inputs = {
nixpkgs = {
# url = "github:nixos/nixpkgs/nixos-unstable";
url = "github:nixos/nixpkgs";
};
};
outputs = { self, nixpkgs }:
let
import-nixpkgs = cudaSupport: import nixpkgs {
system = "x86_64-linux";
config = {
allowUnfree = true;
inherit cudaSupport;
};
};
pkgs-with-cuda = import-nixpkgs true;
pkgs-without-cuda = import-nixpkgs false;
make-shell = pkgs: pkgs.mkShell {
buildInputs = (
with pkgs; [
python3
# For building certain pip packages
cmake
cudatoolkit
swig
]
) ++ (
with pkgs.python3Packages; [
pygame
tensorboard
pytorch-bin
torchaudio-bin
]
);
shellHook =
let
packageList = with pkgs; [
# for PyTorch
stdenv.cc.cc.lib
# for Numpy
zlib
# GL libraries (for gym environment rendering)
libGL
libGLU
# Provides libgthread (for pyqtgraph)
glib.out
xorg.libxcb
];
libPath = nixpkgs.lib.strings.concatMapStringsSep ":" (p: "${p}/lib") packageList;
in
''
export LD_LIBRARY_PATH=${libPath}
export SDL_VIDEODRIVER=x11
export PYTHONPATH=$(pwd):$PYTHONPATH
'';
};
in {
devShells.x86_64-linux = {
default = make-shell pkgs-with-cuda;
intel = make-shell pkgs-without-cuda;
};
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment