Merge branch 'build-careless'
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
# careless
|
||||
|
||||
Scaling and merging of X-ray diffraction data with approximate Bayesian
|
||||
inference (variational merging), built on TensorFlow.
|
||||
|
||||
- Upstream: https://github.com/rs-station/careless
|
||||
- License: MIT
|
||||
|
||||
## How it is built
|
||||
|
||||
Upstream recommends a fresh conda env, but repo.anaconda.com is not
|
||||
reachable from Ra, so the build uses uv instead: it fetches a standalone
|
||||
Python 3.12 into `$PREFIX/python` (upstream supports >=3.9,<3.13), creates
|
||||
`$PREFIX/venv`, and runs `uv pip install careless[cuda]==<version>` into
|
||||
it. The `[cuda]` extra pulls the NVIDIA libraries as pip wheels, so the
|
||||
same install works on GPU and CPU-only Ra nodes.
|
||||
|
||||
`uv` must be on PATH on the build host (e.g. `pip install --user uv`).
|
||||
|
||||
Loading the module puts the venv's `bin/` on `PATH` (the `careless`
|
||||
command is directly available, no activation needed) and sets
|
||||
`CARELESS_ENV` to the venv path.
|
||||
|
||||
## Verifying the install
|
||||
|
||||
Run on a Ra login node after building (in order, cheap to expensive):
|
||||
|
||||
```sh
|
||||
# 1. module is visible and loads
|
||||
module search careless
|
||||
module load careless/<version>
|
||||
|
||||
# 2. modulefile wiring: PATH + CARELESS_ENV
|
||||
which careless # -> .../careless/<version>/venv/bin/careless
|
||||
echo $CARELESS_ENV # -> .../venv
|
||||
|
||||
# 3. venv is self-contained: must resolve inside the module PREFIX,
|
||||
# not the builder's home cache (which may be cleaned later)
|
||||
readlink -f "$CARELESS_ENV/bin/python"
|
||||
|
||||
# 4. CLI entry point; imports the full TensorFlow stack
|
||||
careless --help # usage text, no traceback
|
||||
|
||||
# 5. installed version matches the one requested
|
||||
"$CARELESS_ENV/bin/python" -c "import careless; print(careless.__version__)"
|
||||
|
||||
# 6. GPU pickup (GPU node only; [] on a CPU node is fine)
|
||||
"$CARELESS_ENV/bin/python" -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"
|
||||
```
|
||||
|
||||
Optional end-to-end smoke test with a small unmerged mtz (a few seconds;
|
||||
proves the TF graph builds and the optimizer steps):
|
||||
|
||||
```sh
|
||||
careless mono dHKL <file.mtz> /tmp/careless_test --iterations 10
|
||||
```
|
||||
|
||||
## Adding a new version
|
||||
|
||||
Add the version under `versions:` in `files/config.yaml`, then on a Ra
|
||||
login node: `modbuild build <version>` (modbuild/2.1.2).
|
||||
Executable
+28
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env modbuild
|
||||
|
||||
pbuild::prep() {
|
||||
:
|
||||
}
|
||||
|
||||
pbuild::configure() {
|
||||
# repo.anaconda.com is unreachable from Ra (GnuTLS error), so no conda.
|
||||
# uv fetches a standalone CPython instead; keep it inside PREFIX so the
|
||||
# venv's interpreter symlinks don't depend on the builder's home cache.
|
||||
# modbuild's shell strips ~/.local/bin from PATH; override with UV=/path/to/uv if needed
|
||||
UV="${UV:-$HOME/.local/bin/uv}"
|
||||
# ~/.cache/uv hits the home disk quota; cache under PREFIX (removed after install)
|
||||
export UV_CACHE_DIR="/opt/psi/MX/.uv-cache"
|
||||
export UV_PYTHON_INSTALL_DIR="$PREFIX/python"
|
||||
"$UV" venv --python 3.12 "$PREFIX/venv"
|
||||
}
|
||||
|
||||
pbuild::compile() {
|
||||
:
|
||||
}
|
||||
|
||||
pbuild::install() {
|
||||
UV="${UV:-$HOME/.local/bin/uv}"
|
||||
export UV_CACHE_DIR="/opt/psi/MX/.uv-cache"
|
||||
# [cuda] extra ships the NVIDIA libs via pip wheels; works on CPU-only nodes too
|
||||
"$UV" pip install --python "$PREFIX/venv/bin/python" "careless[cuda]==${V_PKG}"
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
---
|
||||
format: 1
|
||||
careless:
|
||||
defaults:
|
||||
group: MX
|
||||
overlay: base
|
||||
relstage: unstable
|
||||
versions:
|
||||
0.5.4:
|
||||
config:
|
||||
relstage: unstable
|
||||
@@ -0,0 +1,16 @@
|
||||
#%Module1.0
|
||||
|
||||
module-whatis "careless - merging crystallography data with variational inference"
|
||||
module-url "https://github.com/rs-station/careless"
|
||||
module-license "MIT"
|
||||
module-maintainer "MX Data <jiaxin.duan@psi.ch>"
|
||||
|
||||
module-help "
|
||||
careless: scaling and merging of X-ray diffraction data using
|
||||
approximate Bayesian inference (TensorFlow). Installed with the
|
||||
[cuda] extra, so it uses NVIDIA GPUs when available and falls
|
||||
back to CPU otherwise.
|
||||
"
|
||||
|
||||
setenv CARELESS_ENV $PREFIX/venv
|
||||
prepend-path PATH $PREFIX/venv/bin
|
||||
Reference in New Issue
Block a user