GPU programming

I need to do intensive numerics and I think it could be parallelizable.
I have access to a server with an NVIDIA TESLA K20. What would be the good ocaml library to use?
Google hints me to ‘spoc’, but I’m not sure it’s still alive.

2 Likes

Hello. I’m the main developer of SPOC. I’m not intensively working on it currently but it’s still alive. It should work with any Cuda/OpenCL compatible hardware. If you have any issue with it please tell me and I’ll look at it asap :slight_smile:

2 Likes

thanks for the message!
Here is what I get when try to install spoc

#=== ERROR while compiling spoc.20170724 ======================================#
# context     2.0.7 | linux/x86_64 | ocaml-base-compiler.4.07.1 | https://opam.ocaml.org#0eeef63a
# path        ~/.opam/4.07.1/.opam-switch/build/spoc.20170724
# command     ~/.opam/opam-init/hooks/sandbox.sh build make -C Spoc -j1
# exit-code   2
# env-file    ~/.opam/log/spoc-29464-d2c37b.env
# output-file ~/.opam/log/spoc-29464-d2c37b.out
### output ###
# [...]                                                                                                                                                                                               
# \033[34m[Mem.cmx]\033[0m
# \033[34m[Tools.cmx]\033[0m
# \033[34m[KernelOpenCL.cmx]\033[0m
# \033[34m[Kernel.cmx]\033[0m
# \033[34m[KernelCuda.cmx]\033[0m
# \033[34m[spoc.cmx]\033[0m
# \033[31m[spoc.cmxa]\033[0m
# \033[43m\033[30mBuilding WebSpoc\033[0m
# \033[36m[spoc_lib.js]\033[0m
# /bin/sh: ligne 0 : cd: trop d'arguments
# make: *** [Makefile:26: Js/spoc_lib.js] Error 1
# make : on quitte le répertoire « /home/san/.opam/4.07.1/.opam-switch/build/spoc.20170724/Spoc »

<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
┌─ The following actions failed
│ λ build spoc 20170724
└─

This is not directly related to CUDA, but if I understood well from @jrzhao42, one can use owl-symbolic to create computation graphs for any(?) owl computation and export it to ONNX format which can then be loaded and run on GPU using performant libraries.

I use this as an opportunity to ping @jrzhao42 which may correct me or give you more accurate information.

1 Like

Bit of a self plug here, but if your numerical intensive parts are matrix/tensor operations, you can also give a shot to ocaml-torch. There are various examples in the repo and most of them would run on your gpu when available. This relies on the PyTorch library so you benefit from highly optimized cuda kernels.

If you decide to give it a try and run into any issue or have any question let me know.

6 Likes

thanks! I have to think. Currently my code is not in terms of matrix computations, I have to check (and learn) whether it can be converted.