summaryrefslogtreecommitdiff
path: root/cuda
diff options
context:
space:
mode:
authorpolwex <polwex@sortug.com>2025-09-22 16:41:50 +0700
committerpolwex <polwex@sortug.com>2025-09-22 16:41:50 +0700
commitec7479951bf8842a77e65b346e3a2586d2e09a72 (patch)
tree0892afc2c613f748956c9e6298b8d2f9cdfbf71e /cuda
PYTHON CUDA SOLVED FOREVAHHEADmaster
Diffstat (limited to 'cuda')
-rw-r--r--cuda/flashattn/flake.bkp69
-rw-r--r--cuda/flashattn/flake.lock48
-rw-r--r--cuda/flashattn/flake.nix73
-rw-r--r--cuda/flashattn/sentence.py42
-rw-r--r--cuda/nix-python-devenv/.envrc3
-rw-r--r--cuda/nix-python-devenv/.gitignore235
-rw-r--r--cuda/nix-python-devenv/.python-version1
-rw-r--r--cuda/nix-python-devenv/README.md51
-rw-r--r--cuda/nix-python-devenv/devenv.lock103
-rw-r--r--cuda/nix-python-devenv/devenv.nix32
-rw-r--r--cuda/nix-python-devenv/devenv.yaml15
-rw-r--r--cuda/nix-python-devenv/hello.py12
-rw-r--r--cuda/nix-python-devenv/pyproject.toml9
-rw-r--r--cuda/nix-python-devenv/uv.lock59
-rw-r--r--cuda/python/.envrc10
-rw-r--r--cuda/python/.gitignore9
-rw-r--r--cuda/python/devenv.lock103
-rw-r--r--cuda/python/devenv.nix89
-rw-r--r--cuda/python/devenv.yaml16
-rw-r--r--cuda/pythonflake/flake.lock25
-rw-r--r--cuda/pythonflake/flake.nix43
21 files changed, 1047 insertions, 0 deletions
diff --git a/cuda/flashattn/flake.bkp b/cuda/flashattn/flake.bkp
new file mode 100644
index 0000000..a24ebff
--- /dev/null
+++ b/cuda/flashattn/flake.bkp
@@ -0,0 +1,69 @@
+{
+ description = "Torch cuda flake using nix-community cachix";
+
+ nixConfig = {
+ extra-substituters = [
+ "https://nix-community.cachix.org"
+ "https://nix-ai-stuff.cachix.org"
+ "https://ai.cachix.org"
+ "https://cuda-maintainers.cachix.org"
+ ];
+ extra-trusted-public-keys = [
+ "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
+ "cuda-maintainers.cachix.org-1:0dq3bujKpuEPMCX6U4WylrUDZ9JyUG0VpVZa7CNfq5E="
+ "ai.cachix.org-1:N9dzRK+alWwoKXQlnn0H6aUx0lU/mspIoz8hMvGvbbc="
+ "nix-ai-stuff.cachix.org-1:WlUGeVCs26w9xF0/rjyg32PujDqbVMlSHufpj1fqix8="
+ ];
+ };
+ inputs = {
+ nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
+ nix-ai-stuff = {
+ url = "github:BatteredBunny/nix-ai-stuff";
+ inputs.nixpkgs.follows = "nixpkgs";
+ };
+ };
+
+ outputs = {
+ self,
+ nixpkgs,
+ nix-ai-stuff,
+ ...
+ }: let
+ pkgs = import nixpkgs {
+ system = "x86_64-linux";
+ config.allowUnfree = true;
+ config.cudaSupport = true;
+ };
+ in {
+ devShell.x86_64-linux = with pkgs;
+ mkShell rec {
+ venvDir = "./.venv";
+ buildInputs = [
+ (pkgs.python3.withPackages (
+ ps:
+ with ps; [
+ torch
+ accelerate
+ transformers
+ typing-extensions
+ psutil
+ ninja
+ einops
+ packaging
+ sentence-transformers
+ nix-ai-stuff.packages.${pkgs.system}.flash-attn
+ ]
+ ))
+ pkgs.virtualenv
+ pkgs.python3Packages.venvShellHook
+ ];
+ HENLO = "${pkgs.lib.makeLibraryPath buildInputs}";
+ postVenvCreation = ''
+ unset SOURCE_DATE_EPOCH
+ '';
+ shellHook = ''
+ fish
+ '';
+ };
+ };
+}
diff --git a/cuda/flashattn/flake.lock b/cuda/flashattn/flake.lock
new file mode 100644
index 0000000..731a240
--- /dev/null
+++ b/cuda/flashattn/flake.lock
@@ -0,0 +1,48 @@
+{
+ "nodes": {
+ "nix-ai-stuff": {
+ "inputs": {
+ "nixpkgs": [
+ "nixpkgs"
+ ]
+ },
+ "locked": {
+ "lastModified": 1756911915,
+ "narHash": "sha256-2b+GPPCM3Av2rZyuqALsOhnN2LTDmg6GmqBGUm8x/ww=",
+ "owner": "BatteredBunny",
+ "repo": "nix-ai-stuff",
+ "rev": "84db92a097d2c87234e096b880e685cd6423eb88",
+ "type": "github"
+ },
+ "original": {
+ "owner": "BatteredBunny",
+ "repo": "nix-ai-stuff",
+ "type": "github"
+ }
+ },
+ "nixpkgs": {
+ "locked": {
+ "lastModified": 1758277210,
+ "narHash": "sha256-iCGWf/LTy+aY0zFu8q12lK8KuZp7yvdhStehhyX1v8w=",
+ "owner": "nixos",
+ "repo": "nixpkgs",
+ "rev": "8eaee110344796db060382e15d3af0a9fc396e0e",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nixos",
+ "ref": "nixos-unstable",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "root": {
+ "inputs": {
+ "nix-ai-stuff": "nix-ai-stuff",
+ "nixpkgs": "nixpkgs"
+ }
+ }
+ },
+ "root": "root",
+ "version": 7
+}
diff --git a/cuda/flashattn/flake.nix b/cuda/flashattn/flake.nix
new file mode 100644
index 0000000..978bff2
--- /dev/null
+++ b/cuda/flashattn/flake.nix
@@ -0,0 +1,73 @@
+{
+ description = "Torch cuda flake using nix-community cachix";
+
+ nixConfig = {
+ extra-substituters = [
+ "https://nix-community.cachix.org"
+ "https://nix-ai-stuff.cachix.org"
+ "https://ai.cachix.org"
+ "https://cuda-maintainers.cachix.org"
+ ];
+ extra-trusted-public-keys = [
+ "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
+ "cuda-maintainers.cachix.org-1:0dq3bujKpuEPMCX6U4WylrUDZ9JyUG0VpVZa7CNfq5E="
+ "ai.cachix.org-1:N9dzRK+alWwoKXQlnn0H6aUx0lU/mspIoz8hMvGvbbc="
+ "nix-ai-stuff.cachix.org-1:WlUGeVCs26w9xF0/rjyg32PujDqbVMlSHufpj1fqix8="
+ ];
+ };
+ inputs = {
+ nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
+ nix-ai-stuff = {
+ url = "github:BatteredBunny/nix-ai-stuff";
+ inputs.nixpkgs.follows = "nixpkgs";
+ };
+ };
+
+ outputs = {
+ self,
+ nixpkgs,
+ nix-ai-stuff,
+ ...
+ }: let
+ pkgs = import nixpkgs {
+ system = "x86_64-linux";
+ config.allowUnfree = true;
+ config.cudaSupport = true;
+ };
+ in {
+ devShell.x86_64-linux = with pkgs;
+ mkShell rec {
+ venvDir = "./.venv";
+ buildInputs = [
+ (pkgs.python3.withPackages (
+ ps:
+ with ps; [
+ torch
+ accelerate
+ transformers
+ typing-extensions
+ psutil
+ ninja
+ einops
+ packaging
+ sentence-transformers
+ nix-ai-stuff.packages.${pkgs.system}.flash-attn
+ ]
+ ))
+ pkgs.virtualenv
+ pkgs.python3Packages.venvShellHook
+ ];
+ lulz = [
+ pkgs.python3Packages.sentence-transformers
+ nix-ai-stuff.packages.${pkgs.system}.flash-attn
+ ];
+ HENLO = "${pkgs.lib.makeLibraryPath lulz}";
+ postVenvCreation = ''
+ unset SOURCE_DATE_EPOCH
+ '';
+ shellHook = ''
+ fish
+ '';
+ };
+ };
+}
diff --git a/cuda/flashattn/sentence.py b/cuda/flashattn/sentence.py
new file mode 100644
index 0000000..f29927a
--- /dev/null
+++ b/cuda/flashattn/sentence.py
@@ -0,0 +1,42 @@
+# Requires transformers>=4.51.0
+# Requires sentence-transformers>=2.7.0
+import torch
+from sentence_transformers import SentenceTransformer
+
+# Load the model
+# model = SentenceTransformer("Qwen/Qwen3-Embedding-8B")
+
+# We recommend enabling flash_attention_2 for better acceleration and memory saving,
+# together with setting `padding_side` to "left":
+model = SentenceTransformer(
+ "Qwen/Qwen3-Embedding-8B",
+ model_kwargs={"attn_implementation": "flash_attention_2", "device_map": "auto", "dtype": torch.float16},
+ tokenizer_kwargs={"padding_side": "left"},
+)
+
+
+# Flash Attention 2 only supports torch.float16 and torch.bfloat16 dtypes, but the current dype in Qwen3Model is torch.float32. You should run training or inference using Automatic Mixed-Precision via the `with torch.autocast(device_type='torch_device'):` decorator, or load the model with the `torch_dtype` argument. Example: `model = AutoModel.from_pretrained("openai/whisper-tiny", attn_implementation="flash_attention_2", torch_dtype=torch.float16)`
+
+# The queries and documents to embed
+queries = [
+ "What is the capital of China?",
+ "Explain gravity",
+]
+documents = [
+ "The capital of China is Beijing.",
+ "Gravity is a force that attracts two bodies towards each other. It gives weight to physical objects and is responsible for the movement of planets around the sun.",
+]
+
+# with torch.autocast(device_type='torch_device'):
+with torch.no_grad():
+# Encode the queries and documents. Note that queries benefit from using a prompt
+# Here we use the prompt called "query" stored under `model.prompts`, but you can
+# also pass your own prompt via the `prompt` argument
+ query_embeddings = model.encode(queries, prompt_name="query")
+ document_embeddings = model.encode(documents)
+
+# Compute the (cosine) similarity between the query and document embeddings
+similarity = model.similarity(query_embeddings, document_embeddings)
+print(similarity)
+# tensor([[0.7493, 0.0751],
+# [0.0880, 0.6318]])
diff --git a/cuda/nix-python-devenv/.envrc b/cuda/nix-python-devenv/.envrc
new file mode 100644
index 0000000..894571b
--- /dev/null
+++ b/cuda/nix-python-devenv/.envrc
@@ -0,0 +1,3 @@
+source_url "https://raw.githubusercontent.com/cachix/devenv/82c0147677e510b247d8b9165c54f73d32dfd899/direnvrc" "sha256-7u4iDd1nZpxL4tCzmPG0dQgC5V+/44Ba+tHkPob1v2k="
+
+use devenv
diff --git a/cuda/nix-python-devenv/.gitignore b/cuda/nix-python-devenv/.gitignore
new file mode 100644
index 0000000..31b2e3b
--- /dev/null
+++ b/cuda/nix-python-devenv/.gitignore
@@ -0,0 +1,235 @@
+### Linux ###
+*~
+
+# temporary files which can be created if a process still has a handle open of a deleted file
+.fuse_hidden*
+
+# KDE directory preferences
+.directory
+
+# Linux trash folder which might appear on any partition or disk
+.Trash-*
+
+# .nfs files are created when an open file is removed but is still being accessed
+.nfs*
+
+### Python ###
+# Byte-compiled / optimized / DLL files
+__pycache__/
+*.py[cod]
+*$py.class
+
+# C extensions
+*.so
+
+# Distribution / packaging
+.Python
+build/
+develop-eggs/
+dist/
+downloads/
+eggs/
+.eggs/
+lib/
+lib64/
+parts/
+sdist/
+var/
+wheels/
+share/python-wheels/
+*.egg-info/
+.installed.cfg
+*.egg
+MANIFEST
+
+# PyInstaller
+# Usually these files are written by a python script from a template
+# before PyInstaller builds the exe, so as to inject date/other infos into it.
+*.manifest
+*.spec
+
+# Installer logs
+pip-log.txt
+pip-delete-this-directory.txt
+
+# Unit test / coverage reports
+htmlcov/
+.tox/
+.nox/
+.coverage
+.coverage.*
+.cache
+nosetests.xml
+coverage.xml
+*.cover
+*.py,cover
+.hypothesis/
+.pytest_cache/
+cover/
+
+# Translations
+*.mo
+*.pot
+
+# Django stuff:
+*.log
+local_settings.py
+db.sqlite3
+db.sqlite3-journal
+
+# Flask stuff:
+instance/
+.webassets-cache
+
+# Scrapy stuff:
+.scrapy
+
+# Sphinx documentation
+docs/_build/
+
+# PyBuilder
+.pybuilder/
+target/
+
+# Jupyter Notebook
+.ipynb_checkpoints
+
+# IPython
+profile_default/
+ipython_config.py
+
+# pyenv
+# For a library or package, you might want to ignore these files since the code is
+# intended to run in multiple environments; otherwise, check them in:
+# .python-version
+
+# pipenv
+# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
+# However, in case of collaboration, if having platform-specific dependencies or dependencies
+# having no cross-platform support, pipenv may install dependencies that don't work, or not
+# install all needed dependencies.
+#Pipfile.lock
+
+# poetry
+# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
+# This is especially recommended for binary packages to ensure reproducibility, and is more
+# commonly ignored for libraries.
+# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
+#poetry.lock
+
+# pdm
+# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
+#pdm.lock
+# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
+# in version control.
+# https://pdm.fming.dev/#use-with-ide
+.pdm.toml
+
+# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
+__pypackages__/
+
+# Celery stuff
+celerybeat-schedule
+celerybeat.pid
+
+# SageMath parsed files
+*.sage.py
+
+# Environments
+.env
+.venv
+env/
+venv/
+ENV/
+env.bak/
+venv.bak/
+
+# Spyder project settings
+.spyderproject
+.spyproject
+
+# Rope project settings
+.ropeproject
+
+# mkdocs documentation
+/site
+
+# mypy
+.mypy_cache/
+.dmypy.json
+dmypy.json
+
+# Pyre type checker
+.pyre/
+
+# pytype static type analyzer
+.pytype/
+
+# Cython debug symbols
+cython_debug/
+
+# PyCharm
+# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
+# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
+# and can be added to the global gitignore or merged into this file. For a more nuclear
+# option (not recommended) you can uncomment the following to ignore the entire idea folder.
+#.idea/
+
+### Python Patch ###
+# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
+poetry.toml
+
+# ruff
+.ruff_cache/
+
+# LSP config files
+pyrightconfig.json
+
+### VisualStudioCode ###
+.vscode/*
+!.vscode/settings.json
+!.vscode/tasks.json
+!.vscode/launch.json
+!.vscode/extensions.json
+!.vscode/*.code-snippets
+
+# Local History for Visual Studio Code
+.history/
+
+# Built Visual Studio Code Extensions
+*.vsix
+
+### VisualStudioCode Patch ###
+# Ignore all local history of files
+.history
+.ionide
+
+# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,python,linux
+# pixi environments
+.pixi
+*.egg-info
+
+# Personal dev stuff
+scripts/
+_tests/
+.aider*
+
+.devenv
+# Devenv
+.devenv*
+devenv.local.nix
+
+# direnv
+.direnv
+
+# pre-commit
+.pre-commit-config.yaml
+# Devenv
+.devenv*
+devenv.local.nix
+
+# direnv
+.direnv
+
+# pre-commit
+.pre-commit-config.yaml
diff --git a/cuda/nix-python-devenv/.python-version b/cuda/nix-python-devenv/.python-version
new file mode 100644
index 0000000..2c07333
--- /dev/null
+++ b/cuda/nix-python-devenv/.python-version
@@ -0,0 +1 @@
+3.11
diff --git a/cuda/nix-python-devenv/README.md b/cuda/nix-python-devenv/README.md
new file mode 100644
index 0000000..df1ef33
--- /dev/null
+++ b/cuda/nix-python-devenv/README.md
@@ -0,0 +1,51 @@
+# Nix Python Devenv
+
+A Python development environment template using [devenv](https://devenv.sh) with working C bindings,
+managed by [uv](https://docs.astral.sh/uv/) package manager.
+
+A version of this repo with CUDA is available on the
+[cuda branch](https://github.com/clementpoiret/nix-python-devenv/tree/cuda).
+
+## Features
+
+- CUDA toolkit and CUDNN support (see the `cuda` branch)
+- Python 3.x environment
+- Fast package management with uv
+- Automatic environment activation with direnv
+- Example script using numpy
+
+## Installation
+
+1. Install [Nix](https://nixos.org/download/):
+ ```bash
+ sh <(curl -L https://nixos.org/nix/install) --daemon
+ ```
+
+2. Install [devenv](https://devenv.sh/)
+ ```bash
+ nix-env -iA devenv -f https://github.com/NixOS/nixpkgs/tarball/nixpkgs-unstable
+ ```
+
+3. Install [direnv](https://direnv.net/) (optional but recommended)
+
+4. Clone and setup:
+ ```bash
+ git clone --single-branch --branch cuda git@github.com:clementpoiret/nix-python-devenv.git
+
+ # Allow direnv to manage the environment
+ direnv allow
+ ```
+
+## Usage
+
+The environment automatically:
+- Activates the Python virtual environment
+- Sets up LD_LIBRARY_PATH
+- Provides the `hello` command to test C Bindings
+
+Run the sample script:
+```bash
+hello
+```
+
+This will display the output of numpy functions.
diff --git a/cuda/nix-python-devenv/devenv.lock b/cuda/nix-python-devenv/devenv.lock
new file mode 100644
index 0000000..623980f
--- /dev/null
+++ b/cuda/nix-python-devenv/devenv.lock
@@ -0,0 +1,103 @@
+{
+ "nodes": {
+ "devenv": {
+ "locked": {
+ "dir": "src/modules",
+ "lastModified": 1749934215,
+ "owner": "cachix",
+ "repo": "devenv",
+ "rev": "0ad2d684f722b41578b34670428161d996382e64",
+ "type": "github"
+ },
+ "original": {
+ "dir": "src/modules",
+ "owner": "cachix",
+ "repo": "devenv",
+ "type": "github"
+ }
+ },
+ "flake-compat": {
+ "flake": false,
+ "locked": {
+ "lastModified": 1747046372,
+ "owner": "edolstra",
+ "repo": "flake-compat",
+ "rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885",
+ "type": "github"
+ },
+ "original": {
+ "owner": "edolstra",
+ "repo": "flake-compat",
+ "type": "github"
+ }
+ },
+ "git-hooks": {
+ "inputs": {
+ "flake-compat": "flake-compat",
+ "gitignore": "gitignore",
+ "nixpkgs": [
+ "nixpkgs"
+ ]
+ },
+ "locked": {
+ "lastModified": 1749636823,
+ "owner": "cachix",
+ "repo": "git-hooks.nix",
+ "rev": "623c56286de5a3193aa38891a6991b28f9bab056",
+ "type": "github"
+ },
+ "original": {
+ "owner": "cachix",
+ "repo": "git-hooks.nix",
+ "type": "github"
+ }
+ },
+ "gitignore": {
+ "inputs": {
+ "nixpkgs": [
+ "git-hooks",
+ "nixpkgs"
+ ]
+ },
+ "locked": {
+ "lastModified": 1709087332,
+ "owner": "hercules-ci",
+ "repo": "gitignore.nix",
+ "rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
+ "type": "github"
+ },
+ "original": {
+ "owner": "hercules-ci",
+ "repo": "gitignore.nix",
+ "type": "github"
+ }
+ },
+ "nixpkgs": {
+ "locked": {
+ "lastModified": 1749903597,
+ "owner": "NixOS",
+ "repo": "nixpkgs",
+ "rev": "41da1e3ea8e23e094e5e3eeb1e6b830468a7399e",
+ "type": "github"
+ },
+ "original": {
+ "owner": "NixOS",
+ "ref": "nixpkgs-unstable",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "root": {
+ "inputs": {
+ "devenv": "devenv",
+ "git-hooks": "git-hooks",
+ "nixpkgs": "nixpkgs",
+ "pre-commit-hooks": [
+ "git-hooks"
+ ]
+ }
+ }
+ },
+ "root": "root",
+ "version": 7
+}
diff --git a/cuda/nix-python-devenv/devenv.nix b/cuda/nix-python-devenv/devenv.nix
new file mode 100644
index 0000000..5bfedfb
--- /dev/null
+++ b/cuda/nix-python-devenv/devenv.nix
@@ -0,0 +1,32 @@
+{
+ pkgs,
+ lib,
+ ...
+}:
+let
+ buildInputs = with pkgs; [
+ stdenv.cc.cc
+ libuv
+ zlib
+ ];
+in
+{
+ env = {
+ LD_LIBRARY_PATH = "${lib.makeLibraryPath buildInputs}";
+ };
+
+ languages.python = {
+ enable = true;
+ uv = {
+ enable = true;
+ sync.enable = true;
+ };
+ };
+
+ scripts.hello.exec = "uv run python hello.py";
+
+ enterShell = ''
+ . .devenv/state/venv/bin/activate
+ hello
+ '';
+}
diff --git a/cuda/nix-python-devenv/devenv.yaml b/cuda/nix-python-devenv/devenv.yaml
new file mode 100644
index 0000000..84dd44b
--- /dev/null
+++ b/cuda/nix-python-devenv/devenv.yaml
@@ -0,0 +1,15 @@
+# yaml-language-server: $schema=https://devenv.sh/devenv.schema.json
+inputs:
+ nixpkgs:
+ url: github:NixOS/nixpkgs/nixpkgs-unstable
+
+# If you're using non-OSS software, you can set allowUnfree to true.
+# allowUnfree: true
+
+# If you're willing to use a package that's vulnerable
+# permittedInsecurePackages:
+# - "openssl-1.1.1w"
+
+# If you have more than one devenv you can merge them
+#imports:
+# - ./backend
diff --git a/cuda/nix-python-devenv/hello.py b/cuda/nix-python-devenv/hello.py
new file mode 100644
index 0000000..9f27d8a
--- /dev/null
+++ b/cuda/nix-python-devenv/hello.py
@@ -0,0 +1,12 @@
+import numpy as np
+
+
+def main():
+ print("Hello from nix-python-devenv!")
+ print("As you can see, C bindings are correct, because numpy works:")
+ print("a =", a := np.array([1, 2, 3]))
+ print("mean(a) =", a.mean())
+
+
+if __name__ == "__main__":
+ main()
diff --git a/cuda/nix-python-devenv/pyproject.toml b/cuda/nix-python-devenv/pyproject.toml
new file mode 100644
index 0000000..b6d7ebb
--- /dev/null
+++ b/cuda/nix-python-devenv/pyproject.toml
@@ -0,0 +1,9 @@
+[project]
+name = "nix-python-devenv"
+version = "0.1.0"
+description = "Example project with working C bindings!"
+readme = "README.md"
+requires-python = ">=3.11"
+dependencies = [
+ "numpy>=2.1.2",
+]
diff --git a/cuda/nix-python-devenv/uv.lock b/cuda/nix-python-devenv/uv.lock
new file mode 100644
index 0000000..f57d991
--- /dev/null
+++ b/cuda/nix-python-devenv/uv.lock
@@ -0,0 +1,59 @@
+version = 1
+requires-python = ">=3.11"
+
+[[package]]
+name = "nix-python-devenv"
+version = "0.1.0"
+source = { virtual = "." }
+dependencies = [
+ { name = "numpy" },
+]
+
+[package.metadata]
+requires-dist = [{ name = "numpy", specifier = ">=2.1.2" }]
+
+[[package]]
+name = "numpy"
+version = "2.1.2"
+source = { registry = "https://pypi.org/simple" }
+sdist = { url = "https://files.pythonhosted.org/packages/4b/d1/8a730ea07f4a37d94f9172f4ce1d81064b7a64766b460378be278952de75/numpy-2.1.2.tar.gz", hash = "sha256:13532a088217fa624c99b843eeb54640de23b3414b14aa66d023805eb731066c", size = 18878063 }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/aa/9c/9a6ec3ae89cd0648d419781284308f2956d2a61d932b5ac9682c956a171b/numpy-2.1.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:b42a1a511c81cc78cbc4539675713bbcf9d9c3913386243ceff0e9429ca892fe", size = 21154845 },
+ { url = "https://files.pythonhosted.org/packages/02/69/9f05c4ecc75fabf297b17743996371b4c3dfc4d92e15c5c38d8bb3db8d74/numpy-2.1.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:faa88bc527d0f097abdc2c663cddf37c05a1c2f113716601555249805cf573f1", size = 13789409 },
+ { url = "https://files.pythonhosted.org/packages/34/4e/f95c99217bf77bbfaaf660d693c10bd0dc03b6032d19316d316088c9e479/numpy-2.1.2-cp311-cp311-macosx_14_0_arm64.whl", hash = "sha256:c82af4b2ddd2ee72d1fc0c6695048d457e00b3582ccde72d8a1c991b808bb20f", size = 5352097 },
+ { url = "https://files.pythonhosted.org/packages/06/13/f5d87a497c16658e9af8920449b0b5692b469586b8231340c672962071c5/numpy-2.1.2-cp311-cp311-macosx_14_0_x86_64.whl", hash = "sha256:13602b3174432a35b16c4cfb5de9a12d229727c3dd47a6ce35111f2ebdf66ff4", size = 6891195 },
+ { url = "https://files.pythonhosted.org/packages/6c/89/691ac07429ac061b344d5e37fa8e94be51a6017734aea15f2d9d7c6d119a/numpy-2.1.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1ebec5fd716c5a5b3d8dfcc439be82a8407b7b24b230d0ad28a81b61c2f4659a", size = 13895153 },
+ { url = "https://files.pythonhosted.org/packages/23/69/538317f0d925095537745f12aced33be1570bbdc4acde49b33748669af96/numpy-2.1.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e2b49c3c0804e8ecb05d59af8386ec2f74877f7ca8fd9c1e00be2672e4d399b1", size = 16338306 },
+ { url = "https://files.pythonhosted.org/packages/af/03/863fe7062c2106d3c151f7df9353f2ae2237c1dd6900f127a3eb1f24cb1b/numpy-2.1.2-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:2cbba4b30bf31ddbe97f1c7205ef976909a93a66bb1583e983adbd155ba72ac2", size = 16710893 },
+ { url = "https://files.pythonhosted.org/packages/70/77/0ad9efe25482009873f9660d29a40a8c41a6f0e8b541195e3c95c70684c5/numpy-2.1.2-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:8e00ea6fc82e8a804433d3e9cedaa1051a1422cb6e443011590c14d2dea59146", size = 14398048 },
+ { url = "https://files.pythonhosted.org/packages/3e/0f/e785fe75544db9f2b0bb1c181e13ceff349ce49753d807fd9672916aa06d/numpy-2.1.2-cp311-cp311-win32.whl", hash = "sha256:5006b13a06e0b38d561fab5ccc37581f23c9511879be7693bd33c7cd15ca227c", size = 6533458 },
+ { url = "https://files.pythonhosted.org/packages/d4/96/450054662295125af861d48d2c4bc081dadcf1974a879b2104613157aa62/numpy-2.1.2-cp311-cp311-win_amd64.whl", hash = "sha256:f1eb068ead09f4994dec71c24b2844f1e4e4e013b9629f812f292f04bd1510d9", size = 12870896 },
+ { url = "https://files.pythonhosted.org/packages/a0/7d/554a6838f37f3ada5a55f25173c619d556ae98092a6e01afb6e710501d70/numpy-2.1.2-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:d7bf0a4f9f15b32b5ba53147369e94296f5fffb783db5aacc1be15b4bf72f43b", size = 20848077 },
+ { url = "https://files.pythonhosted.org/packages/b0/29/cb48a402ea879e645b16218718f3f7d9588a77d674a9dcf22e4c43487636/numpy-2.1.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:b1d0fcae4f0949f215d4632be684a539859b295e2d0cb14f78ec231915d644db", size = 13493242 },
+ { url = "https://files.pythonhosted.org/packages/56/44/f899b0581766c230da42f751b7b8896d096640b19b312164c267e48d36cb/numpy-2.1.2-cp312-cp312-macosx_14_0_arm64.whl", hash = "sha256:f751ed0a2f250541e19dfca9f1eafa31a392c71c832b6bb9e113b10d050cb0f1", size = 5089219 },
+ { url = "https://files.pythonhosted.org/packages/79/8f/b987070d45161a7a4504afc67ed38544ed2c0ed5576263599a0402204a9c/numpy-2.1.2-cp312-cp312-macosx_14_0_x86_64.whl", hash = "sha256:bd33f82e95ba7ad632bc57837ee99dba3d7e006536200c4e9124089e1bf42426", size = 6620167 },
+ { url = "https://files.pythonhosted.org/packages/c4/a7/af3329fda3c3ec31d9b650e42bbcd3422fc62a765cbb1405fde4177a0996/numpy-2.1.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1b8cde4f11f0a975d1fd59373b32e2f5a562ade7cde4f85b7137f3de8fbb29a0", size = 13604905 },
+ { url = "https://files.pythonhosted.org/packages/9b/b4/e3c7e6fab0f77fff6194afa173d1f2342073d91b1d3b4b30b17c3fb4407a/numpy-2.1.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6d95f286b8244b3649b477ac066c6906fbb2905f8ac19b170e2175d3d799f4df", size = 16041825 },
+ { url = "https://files.pythonhosted.org/packages/e9/50/6828e66a78aa03147c111f84d55f33ce2dde547cb578d6744a3b06a0124b/numpy-2.1.2-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:ab4754d432e3ac42d33a269c8567413bdb541689b02d93788af4131018cbf366", size = 16409541 },
+ { url = "https://files.pythonhosted.org/packages/bf/72/66af7916d9c3c6dbfbc8acdd4930c65461e1953374a2bc43d00f948f004a/numpy-2.1.2-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:e585c8ae871fd38ac50598f4763d73ec5497b0de9a0ab4ef5b69f01c6a046142", size = 14081134 },
+ { url = "https://files.pythonhosted.org/packages/dc/5a/59a67d84f33fe00ae74f0b5b69dd4f93a586a4aba7f7e19b54b2133db038/numpy-2.1.2-cp312-cp312-win32.whl", hash = "sha256:9c6c754df29ce6a89ed23afb25550d1c2d5fdb9901d9c67a16e0b16eaf7e2550", size = 6237784 },
+ { url = "https://files.pythonhosted.org/packages/4c/79/73735a6a5dad6059c085f240a4e74c9270feccd2bc66e4d31b5ca01d329c/numpy-2.1.2-cp312-cp312-win_amd64.whl", hash = "sha256:456e3b11cb79ac9946c822a56346ec80275eaf2950314b249b512896c0d2505e", size = 12568254 },
+ { url = "https://files.pythonhosted.org/packages/16/72/716fa1dbe92395a9a623d5049203ff8ddb0cfce65b9df9117c3696ccc011/numpy-2.1.2-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:a84498e0d0a1174f2b3ed769b67b656aa5460c92c9554039e11f20a05650f00d", size = 20834690 },
+ { url = "https://files.pythonhosted.org/packages/1e/fb/3e85a39511586053b5c6a59a643879e376fae22230ebfef9cfabb0e032e2/numpy-2.1.2-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:4d6ec0d4222e8ffdab1744da2560f07856421b367928026fb540e1945f2eeeaf", size = 13507474 },
+ { url = "https://files.pythonhosted.org/packages/35/eb/5677556d9ba13436dab51e129f98d4829d95cd1b6bd0e199c14485a4bdb9/numpy-2.1.2-cp313-cp313-macosx_14_0_arm64.whl", hash = "sha256:259ec80d54999cc34cd1eb8ded513cb053c3bf4829152a2e00de2371bd406f5e", size = 5074742 },
+ { url = "https://files.pythonhosted.org/packages/3e/c5/6c5ef5ba41b65a7e51bed50dbf3e1483eb578055633dd013e811a28e96a1/numpy-2.1.2-cp313-cp313-macosx_14_0_x86_64.whl", hash = "sha256:675c741d4739af2dc20cd6c6a5c4b7355c728167845e3c6b0e824e4e5d36a6c3", size = 6606787 },
+ { url = "https://files.pythonhosted.org/packages/08/ac/f2f29dd4fd325b379c7dc932a0ebab22f0e031dbe80b2f6019b291a3a544/numpy-2.1.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:05b2d4e667895cc55e3ff2b56077e4c8a5604361fc21a042845ea3ad67465aa8", size = 13601333 },
+ { url = "https://files.pythonhosted.org/packages/44/26/63f5f4e5089654dfb858f4892215ed968cd1a68e6f4a83f9961f84f855cb/numpy-2.1.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:43cca367bf94a14aca50b89e9bc2061683116cfe864e56740e083392f533ce7a", size = 16038090 },
+ { url = "https://files.pythonhosted.org/packages/1d/21/015e0594de9c3a8d5edd24943d2bd23f102ec71aec026083f822f86497e2/numpy-2.1.2-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:76322dcdb16fccf2ac56f99048af32259dcc488d9b7e25b51e5eca5147a3fb98", size = 16410865 },
+ { url = "https://files.pythonhosted.org/packages/df/01/c1bcf9e6025d79077fbf3f3ee503b50aa7bfabfcd8f4b54f5829f4c00f3f/numpy-2.1.2-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:32e16a03138cabe0cb28e1007ee82264296ac0983714094380b408097a418cfe", size = 14078077 },
+ { url = "https://files.pythonhosted.org/packages/ba/06/db9d127d63bd11591770ba9f3d960f8041e0f895184b9351d4b1b5b56983/numpy-2.1.2-cp313-cp313-win32.whl", hash = "sha256:242b39d00e4944431a3cd2db2f5377e15b5785920421993770cddb89992c3f3a", size = 6234904 },
+ { url = "https://files.pythonhosted.org/packages/a9/96/9f61f8f95b6e0ea0aa08633b704c75d1882bdcb331bdf8bfd63263b25b00/numpy-2.1.2-cp313-cp313-win_amd64.whl", hash = "sha256:f2ded8d9b6f68cc26f8425eda5d3877b47343e68ca23d0d0846f4d312ecaa445", size = 12561910 },
+ { url = "https://files.pythonhosted.org/packages/36/b8/033f627821784a48e8f75c218033471eebbaacdd933f8979c79637a1b44b/numpy-2.1.2-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:2ffef621c14ebb0188a8633348504a35c13680d6da93ab5cb86f4e54b7e922b5", size = 20857719 },
+ { url = "https://files.pythonhosted.org/packages/96/46/af5726fde5b74ed83f2f17a73386d399319b7ed4d51279fb23b721d0816d/numpy-2.1.2-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:ad369ed238b1959dfbade9018a740fb9392c5ac4f9b5173f420bd4f37ba1f7a0", size = 13518826 },
+ { url = "https://files.pythonhosted.org/packages/db/6e/8ce677edf36da1c4dae80afe5529f47690697eb55b4864673af260ccea7b/numpy-2.1.2-cp313-cp313t-macosx_14_0_arm64.whl", hash = "sha256:d82075752f40c0ddf57e6e02673a17f6cb0f8eb3f587f63ca1eaab5594da5b17", size = 5115036 },
+ { url = "https://files.pythonhosted.org/packages/6a/ba/3cce44fb1b8438042c11847048812a776f75ee0e7070179c22e4cfbf420c/numpy-2.1.2-cp313-cp313t-macosx_14_0_x86_64.whl", hash = "sha256:1600068c262af1ca9580a527d43dc9d959b0b1d8e56f8a05d830eea39b7c8af6", size = 6628641 },
+ { url = "https://files.pythonhosted.org/packages/59/c8/e722998720ccbd35ffbcf1d1b8ed0aa2304af88d3f1c38e06ebf983599b3/numpy-2.1.2-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a26ae94658d3ba3781d5e103ac07a876b3e9b29db53f68ed7df432fd033358a8", size = 13574803 },
+ { url = "https://files.pythonhosted.org/packages/7c/8e/fc1fdd83a55476765329ac2913321c4aed5b082a7915095628c4ca30ea72/numpy-2.1.2-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:13311c2db4c5f7609b462bc0f43d3c465424d25c626d95040f073e30f7570e35", size = 16021174 },
+ { url = "https://files.pythonhosted.org/packages/2a/b6/a790742aa88067adb4bd6c89a946778c1417d4deaeafce3ca928f26d4c52/numpy-2.1.2-cp313-cp313t-musllinux_1_1_x86_64.whl", hash = "sha256:2abbf905a0b568706391ec6fa15161fad0fb5d8b68d73c461b3c1bab6064dd62", size = 16400117 },
+ { url = "https://files.pythonhosted.org/packages/48/6f/129e3c17e3befe7fefdeaa6890f4c4df3f3cf0831aa053802c3862da67aa/numpy-2.1.2-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:ef444c57d664d35cac4e18c298c47d7b504c66b17c2ea91312e979fcfbdfb08a", size = 14066202 },
+]
diff --git a/cuda/python/.envrc b/cuda/python/.envrc
new file mode 100644
index 0000000..7e9a2d6
--- /dev/null
+++ b/cuda/python/.envrc
@@ -0,0 +1,10 @@
+export DIRENV_WARN_TIMEOUT=20s
+
+eval "$(devenv direnvrc)"
+
+# `use devenv` supports the same options as the `devenv shell` command.
+#
+# To silence the output, use `--quiet`.
+#
+# Example usage: use devenv --quiet --impure --option services.postgres.enable:bool true
+use devenv
diff --git a/cuda/python/.gitignore b/cuda/python/.gitignore
new file mode 100644
index 0000000..4d058db
--- /dev/null
+++ b/cuda/python/.gitignore
@@ -0,0 +1,9 @@
+# Devenv
+.devenv*
+devenv.local.nix
+
+# direnv
+.direnv
+
+# pre-commit
+.pre-commit-config.yaml
diff --git a/cuda/python/devenv.lock b/cuda/python/devenv.lock
new file mode 100644
index 0000000..be967d0
--- /dev/null
+++ b/cuda/python/devenv.lock
@@ -0,0 +1,103 @@
+{
+ "nodes": {
+ "devenv": {
+ "locked": {
+ "dir": "src/modules",
+ "lastModified": 1758469077,
+ "owner": "cachix",
+ "repo": "devenv",
+ "rev": "0a84e6e5cd0ab128a9336f77a86a2d3f4a5b5dee",
+ "type": "github"
+ },
+ "original": {
+ "dir": "src/modules",
+ "owner": "cachix",
+ "repo": "devenv",
+ "type": "github"
+ }
+ },
+ "flake-compat": {
+ "flake": false,
+ "locked": {
+ "lastModified": 1747046372,
+ "owner": "edolstra",
+ "repo": "flake-compat",
+ "rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885",
+ "type": "github"
+ },
+ "original": {
+ "owner": "edolstra",
+ "repo": "flake-compat",
+ "type": "github"
+ }
+ },
+ "git-hooks": {
+ "inputs": {
+ "flake-compat": "flake-compat",
+ "gitignore": "gitignore",
+ "nixpkgs": [
+ "nixpkgs"
+ ]
+ },
+ "locked": {
+ "lastModified": 1758108966,
+ "owner": "cachix",
+ "repo": "git-hooks.nix",
+ "rev": "54df955a695a84cd47d4a43e08e1feaf90b1fd9b",
+ "type": "github"
+ },
+ "original": {
+ "owner": "cachix",
+ "repo": "git-hooks.nix",
+ "type": "github"
+ }
+ },
+ "gitignore": {
+ "inputs": {
+ "nixpkgs": [
+ "git-hooks",
+ "nixpkgs"
+ ]
+ },
+ "locked": {
+ "lastModified": 1709087332,
+ "owner": "hercules-ci",
+ "repo": "gitignore.nix",
+ "rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
+ "type": "github"
+ },
+ "original": {
+ "owner": "hercules-ci",
+ "repo": "gitignore.nix",
+ "type": "github"
+ }
+ },
+ "nixpkgs": {
+ "locked": {
+ "lastModified": 1755783167,
+ "owner": "cachix",
+ "repo": "devenv-nixpkgs",
+ "rev": "4a880fb247d24fbca57269af672e8f78935b0328",
+ "type": "github"
+ },
+ "original": {
+ "owner": "cachix",
+ "ref": "rolling",
+ "repo": "devenv-nixpkgs",
+ "type": "github"
+ }
+ },
+ "root": {
+ "inputs": {
+ "devenv": "devenv",
+ "git-hooks": "git-hooks",
+ "nixpkgs": "nixpkgs",
+ "pre-commit-hooks": [
+ "git-hooks"
+ ]
+ }
+ }
+ },
+ "root": "root",
+ "version": 7
+}
diff --git a/cuda/python/devenv.nix b/cuda/python/devenv.nix
new file mode 100644
index 0000000..c32e55f
--- /dev/null
+++ b/cuda/python/devenv.nix
@@ -0,0 +1,89 @@
+{
+ pkgs,
+ lib,
+ config,
+ inputs,
+ ...
+}: let
+ cpkgs = import inputs.nixpkgs {
+ system = pkgs.system;
+ config = {
+ allowUnfree = true;
+ cudaSupport = true;
+ };
+ };
+in {
+ # https://devenv.sh/basics/
+ env.GREET = "devenv";
+
+ # env.LD_LIBRARY_PATH = "/run/opengl-driver/lib";
+ # env.LD_LIBRARY_PATH = "${pkgs.glibc}/lib";
+ # env.CUDA_HOME = pkgs.cudaPackages.cudatoolkit;
+ # env.CUDA_PATH = pkgs.cudaPackages.cudatoolkit;
+
+ # env.LD_LIBRARY_PATH = "/run/opengl-driver/lib:" + lib.makeLibraryPath config.packages;
+ # env.LD_LIBRARY_PATH = "/run/opengl-driver/lib";
+ # # # Ensure Nix packages are discoverable by Python
+ # env.PYTHONPATH = lib.makeSearchPath "lib/python3.13/site-packages" pythonPkgs;
+
+ # https://devenv.sh/packages/
+ packages = with cpkgs; [
+ git
+ # glib
+ # glibc
+ # libGL
+ # libGLU
+ # cudaPackages.cudatoolkit
+ # cudaPackages.cuda_cccl
+ # cudaPackages.cudnn
+ # cudaPackages.cuda_nvcc
+ # stdenv.cc.cc.lib
+ # zlib
+ python3.withPackages
+ (ps:
+ with ps; [
+ torch
+ ])
+ ];
+
+ # https://devenv.sh/languages/
+ # languages.rust.enable = true;
+
+ languages.python = {
+ enable = true;
+ venv.enable = true;
+ };
+ # https://devenv.sh/processes/
+ # processes.dev.exec = "${lib.getExe pkgs.watchexec} -n -- ls -la";
+
+ # https://devenv.sh/services/
+ # services.postgres.enable = true;
+
+ # https://devenv.sh/scripts/
+ scripts.hello.exec = ''
+ echo hello from $GREET
+ '';
+
+ # https://devenv.sh/basics/
+ enterShell = ''
+ hello # Run scripts directly
+ git --version # Use packages
+ '';
+
+ # https://devenv.sh/tasks/
+ # tasks = {
+ # "myproj:setup".exec = "mytool build";
+ # "devenv:enterShell".after = [ "myproj:setup" ];
+ # };
+
+ # https://devenv.sh/tests/
+ enterTest = ''
+ echo "Running tests"
+ git --version | grep --color=auto "${pkgs.git.version}"
+ '';
+
+ # https://devenv.sh/git-hooks/
+ # git-hooks.hooks.shellcheck.enable = true;
+
+ # See full reference at https://devenv.sh/reference/options/
+}
diff --git a/cuda/python/devenv.yaml b/cuda/python/devenv.yaml
new file mode 100644
index 0000000..2518b10
--- /dev/null
+++ b/cuda/python/devenv.yaml
@@ -0,0 +1,16 @@
+# yaml-language-server: $schema=https://devenv.sh/devenv.schema.json
+inputs:
+ nixpkgs:
+ url: github:cachix/devenv-nixpkgs/rolling
+
+# If you're using non-OSS software, you can set allowUnfree to true.
+allowUnfree: true
+cudaSupport: true
+
+# If you're willing to use a package that's vulnerable
+# permittedInsecurePackages:
+# - "openssl-1.1.1w"
+
+# If you have more than one devenv you can merge them
+#imports:
+# - ./backend
diff --git a/cuda/pythonflake/flake.lock b/cuda/pythonflake/flake.lock
new file mode 100644
index 0000000..90937b2
--- /dev/null
+++ b/cuda/pythonflake/flake.lock
@@ -0,0 +1,25 @@
+{
+ "nodes": {
+ "nixpkgs": {
+ "locked": {
+ "lastModified": 1758446476,
+ "narHash": "sha256-5rdAi7CTvM/kSs6fHe1bREIva5W3TbImsto+dxG4mBo=",
+ "owner": "NixOS",
+ "repo": "nixpkgs",
+ "rev": "a1f79a1770d05af18111fbbe2a3ab2c42c0f6cd0",
+ "type": "github"
+ },
+ "original": {
+ "id": "nixpkgs",
+ "type": "indirect"
+ }
+ },
+ "root": {
+ "inputs": {
+ "nixpkgs": "nixpkgs"
+ }
+ }
+ },
+ "root": "root",
+ "version": 7
+}
diff --git a/cuda/pythonflake/flake.nix b/cuda/pythonflake/flake.nix
new file mode 100644
index 0000000..27cac81
--- /dev/null
+++ b/cuda/pythonflake/flake.nix
@@ -0,0 +1,43 @@
+{
+ description = "Torch cuda flake using nix-community cachix";
+
+ nixConfig = {
+ extra-substituters = [
+ "https://nix-community.cachix.org"
+ "https://cuda-maintainers.cachix.org"
+ ];
+ extra-trusted-public-keys = [
+ "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
+ "cuda-maintainers.cachix.org-1:0dq3bujKpuEPMCX6U4WylrUDZ9JyUG0VpVZa7CNfq5E="
+ ];
+ };
+
+ outputs = {
+ self,
+ nixpkgs,
+ }: let
+ pkgs = import nixpkgs {
+ system = "x86_64-linux";
+ config.allowUnfree = true;
+ config.cudaSupport = true;
+ };
+ in {
+ devShell.x86_64-linux = with pkgs;
+ mkShell {
+ venvDir = "./.venv";
+ buildInputs = [
+ (pkgs.python3.withPackages (
+ ps:
+ with ps; [
+ torch
+ ]
+ ))
+ pkgs.virtualenv
+ pkgs.python3Packages.venvShellHook
+ ];
+ postVenvCreation = ''
+ unset SOURCE_DATE_EPOCH
+ '';
+ };
+ };
+}