Hello,
I am new to Guix and want to create a guix package for the free
machine learning framework CIANNA. It has little dependencies (openblas
mainly), is written in C and has a python wrapper. The basic
installation method is to download the source code then run the
compile.cp file inside that will handle both the C compilation and run
python_module_setup.py. I naively picked "copy-build-system" as my build
system and manually inserted a phase after 'install' that run compile.cp
with the according flags and paths toward the guix versions of the
dependencies. It worked and I am able to run CIANNA in a guix shell with
its package and python3 but ONLY if I manually append the path to CIANNA
library at the begining of my python code, otherwise "import CIANNA"
return a library not found error. I know that when I run a guix shell
with python and python-xyz, the environment is setup so that for example
numpy is found automatically without having to manually find and append
its path at the begining of each python code. My question is therefore
the following : how can I have my CIANNA package automatically found by
python when creating the environment without having to append its path
everytime ? Should I change the build-system ?
Below is a copy of my current implementation. As I am a beginer I gladly
welcome any advices (even unrelated to my question)
(define-module (cianna)
#:use-module (guix)
#:use-module ((guix licenses)#:prefix license:)
#:use-module (gnu packages)
#:use-module (guix build-system copy)
#:use-module (guix git-download)
#:use-module (gnu packages gcc)
#:use-module (gnu packages maths);; openBLAS
#:use-module (gnu packages python)
#:use-module (gnu packages python-xyz);; numpy
#:use-module (gnu packages python-build);; python-setuptools
)
(define-public cianna-cpu
(package
(name "cianna-cpu")
(version "1.0.0.0")
(source
(origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/Deyht/CIANNA.git")
(commit "8b34ac4f0fa5fd91adbaed0c8708e6cfa39335e9")))
(file-name (git-file-name name version))
(sha256 (base32 "05pzlm879sfy7wh4x9db1b60r6qqn05qprg0z3w36wl1d1ix4gv0"))))
(inputs
(listgcc openblas python python-numpy python-setuptools))
(build-system copy-build-system)
(arguments
(list#:phases
#~(modify-phases %standard-phases
(add-after 'install'manual_install
(lambda* (#:key inputs #:allow-other-keys)
(let*((gcc (assoc-ref inputs "gcc")))
(let((current-dir (getcwd)))
(substitute* "compile.cp"
(("/usr/bin/gcc")(string-append gcc "/bin/gcc"))
)
(invoke "./compile.cp""BLAS""OPEN_MP""PY_INTERF")
(invoke "export"(string-append "PYTHONPATH=$PYTHONPATH:"#$output))
(invoke
"sed""-i""s/comp_meth=\"C_CUDA/comp_meth=\"C_BLAS/g""examples/MNIST/mnist_train.py")
(invoke
"sed""-i""s/sys.path.insert/#sys.path.insert/g""examples/MNIST/mnist_train.py")
#t))
))
(add-after 'compress-documentation'move_libs
(lambda* (#:key inputs #:allow-other-keys)
(let*((gcc (assoc-ref inputs "gcc")))
(invoke "cp""-r""src/build"(string-append #$output "/src"))
(invoke "cp""-r""examples/MNIST/mnist_train.py"(string-append #$output
"/examples/MNIST/mnist_train.py"))
#t)
))
)
))
(home-page "")
(synopsis "")
(description "CIANNA is a general-purpose deep learning framework
primarily developed and used for astronomical data analysis.
Functionalities and optimizations are added based on relevance for
astrophysical problem-solving. CIANNA can be used to build and train
large neural network models for various tasks and is provided with a
high-level Python interface (similar to keras, pytorch, etc.). One of
the specificities of CIANNA is its custom implementation of a
YOLO-inspired object detector used in the context of galaxy detection in
2D or 3D radio-astronomical data products. The framework is fully
GPU-accelerated through low-level CUDA programming.")
(license license:asl2.0)))
Thank you in advance,
Aristide Doussot
LUX - Observatoire de Paris