Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reproducible Python virtual environment using uv and nix #1387

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions flake.lock

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

11 changes: 11 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
in { devShells.default = import ./shell.nix { inherit pkgs; }; });
}
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ dependencies = [
"torch",
"outlines_core==0.1.26",
"genson",
"pre-commit>=4.0.1",
]
dynamic = ["version"]

Expand Down
73 changes: 73 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{ pkgs ? import <nixpkgs> { config = { allowUnfree = true; }; } }:

(pkgs.buildFHSEnv {
name = "dottxt-ai";
targetPkgs = pkgs:
with pkgs; [
autoconf
binutils
cmake
cudatoolkit
curl
freeglut
gcc13
git
gitRepo
gnumake
gnupg
gperf
libGL
libGLU
linuxPackages.nvidia_x11
m4
ncurses5
procps
python311
stdenv.cc
unzip
util-linux
uv
xorg.libX11
xorg.libXext
xorg.libXi
xorg.libXmu
xorg.libXrandr
xorg.libXv
zlib
];

multiPkgs = pkgs: with pkgs; [ zlib ];

runScript = "bash";

profile = ''
# CUDA paths
export CUDA_HOME=${pkgs.cudatoolkit}
export CUDA_PATH=${pkgs.cudatoolkit}

# Ensure proper binary paths are included
export PATH=${pkgs.gcc13}/bin:${pkgs.cudatoolkit}/bin:$PATH

# Set library paths, including additional directories for CUPTI
export LD_LIBRARY_PATH=${pkgs.cudatoolkit}/lib64:${pkgs.cudatoolkit}/extras/CUPTI/lib64:${pkgs.linuxPackages.nvidia_x11}/lib:$LD_LIBRARY_PATH

# Add static library paths to EXTRA_LDFLAGS for the linker
export EXTRA_LDFLAGS="-L${pkgs.cudatoolkit}/lib64 -L${pkgs.cudatoolkit}/extras/CUPTI/lib64 -L${pkgs.linuxPackages.nvidia_x11}/lib -L${pkgs.cudatoolkit}/libdevice $EXTRA_LDFLAGS"
export EXTRA_CCFLAGS="-I${pkgs.cudatoolkit}/include $EXTRA_CCFLAGS"

# Set CMake paths
export CMAKE_PREFIX_PATH=${pkgs.cudatoolkit}:${pkgs.linuxPackages.nvidia_x11}:$CMAKE_PREFIX_PATH

# C++ and CC flags
export CXXFLAGS="--std=c++17 $EXTRA_CCFLAGS"
export CC=${pkgs.gcc13}/bin/gcc
export CXX=${pkgs.gcc13}/bin/g++

# NVCC flags to use the right compiler
export NVCC_FLAGS="-ccbin ${pkgs.gcc13}/bin/gcc"
'';

structuredAttrs__ = {
stdenv = pkgs.stdenv.overrideCC pkgs.stdenv.cc pkgs.gcc13;
};
}).env
Loading
Loading