cgg-bern / AlgoHex

GNU Affero General Public License v3.0
16 stars 5 forks source link

Support Gurobi-less quantization #15

Open mheistermann opened 5 months ago

mheistermann commented 5 months ago

We can now build without gurobi, but the current code will not acutally use the new QGP3D quantization due to some gurobi-based ifdefs. I'm hacking together a quick patch.

To include it in the main branch, we'll need a bit better logic so AlgoHex can also still be used (e.g. to create seamless maps) without either Gurobi or Bonmin installed.

Idea: Make sure QGP3D cmake does not create a QGP3D target if the dependencies are not met (but won't fail the entire config process, just output a loud warning) ; then in AlgoHex CMake, set a config.hh variable informing on the existence of QGP3D.

mheistermann commented 5 months ago

Works for me now 👍 Commands used:

cd /path/to/AlgoHex
podman build --memory 128G -t algohex .
podman run --rm --memory 64G --volume .:/work algohex HexMeshing -i /work/demo/HexMeshing/cylinder.ovm 2>&1 | tee cyl.log

(Lower memory limit values will likely work. If you are on MacOS or windows, the podman machine (VM) in which the containers run needs to be assigned a sufficient amount of memory.) This should also work with docker instead of podman if you have it installed - untested though.

otaolafranc commented 4 months ago

Hello, is there a planning to give the instructions of gurobi-less installation without using a VM/docker? thanks in advance :)

mheistermann commented 4 months ago

You can use the contents of the Dockerfile as instructions, let me know if you run into any issues. Make sure to use the dev/dockerfile-without-gurobi branch.

Unfortunately I currently don't have time to clean up this change (to allow creating seamless maps, I broke that for simplicity) and create documentation :/ When I do find the time, I'll probably do #14 too, to make it super easy to download&run.

EDIT: to avoid potential misunderstandings, on Linux, Podman will use containers, no VM involved. Maybe this makes it an option for you for simple builds.

otaolafranc commented 4 months ago

Hello @mheistermann I have created an script that at least for my OS works using the dockerFile: the main differences is that I needed to install extra dependencies in comparation to the dockerFile (in bold).

Nproc=8
installationPath=$HOME/Programs
cd $installationPath

rm -fr AlgoHex
git clone --single-branch --branch dev/dockerfile-without-gurobi  https://github.com/cgg-bern/AlgoHex.git

sudo apt-get update
sudo apt-get install -y --no-install-recommends binutils  build-essential  ca-certificates  clang  cmake  curl  git  libc-dev  liblapack-dev  libopenblas64-serial-dev  libopenmpi-dev  libtool  locales  ninja-build  time  tzdata  wget  pkg-config  libgmp-dev  libomp-dev  gfortran  clang

mkdir -p /usr/src/coin-or 
mkdir -p /opt/coin-or
cd /usr/src/coin-or
sudo wget https://raw.githubusercontent.com/coin-or/coinbrew/master/coinbrew
sudo chmod +x coinbrew

cd /usr/src/coin-or 
sudo ./coinbrew fetch https://github.com/coin-or-tools/ThirdParty-Mumps@3.0.5
sudo ./coinbrew fetch Ipopt@3.14.13 --skip-update
sudo ./coinbrew fetch Bonmin@master --skip-update
sudo ./coinbrew build Ipopt@3.14.13 --verbosity 2 --skip-update --prefix=/opt/coin-or --parallel-jobs $Nproc --tests none 
sudo ./coinbrew build Bonmin@master --verbosity 2 --skip-update --prefix=/opt/coin-or --parallel-jobs $Nproc --tests none 

sudo ln -s /opt/coin-or/include/coin-or /opt/coin-or/include/coin

#extra dependencies compared to the dockerFile installed
sudo apt-get install libgtest-dev
cd /usr/src/gtest
sudo cmake CMakeLists.txt
sudo make
ln -s lib/*.a /usr/lib
sudo apt install libstdc++-12-dev
#end of extra dependencies

cd $installationPath/AlgoHex

mkdir build
cd build

echo "export LD_LIBRARY_PATH=/opt/coin-or/lib" >>$HOME/.bashrc
echo "export DYLD_LIBRARY_PATH=/opt/coin-or/lib" >>$HOME/.bashrc
echo "export IPOPT_HOME=/opt/coin-or" >>$HOME/.bashrc
echo "export CBC_DIR=/opt/coin-or" >>$HOME/.bashrc

source ~/.bashrc

cmake -G Ninja -D CMAKE_BUILD_TYPE=Release -D CMAKE_CXX_COMPILER=clang++ -D CMAKE_C_COMPILER=clang -D CMAKE_CXX_FLAGS="-march=native" -D BONMIN_ROOT_DIR=/opt/coin-or ..
ninja

ln -s ./Build/bin/* /usr/local/bin

regards