rmcantin / bayesopt

BayesOpt: A toolbox for bayesian optimization, experimental design and stochastic bandits.
GNU Affero General Public License v3.0
400 stars 93 forks source link

example: Build + Install on Google Colabratory w/ Python 3.6 #26

Open cjekel opened 4 years ago

cjekel commented 4 years ago

Hi Ruben,

Thank you for this very nice Bayesian Optimization library! It works very well, and has some well thought out defaults and features! :-)

I managed to get this running on Google Colaboratory in a Python 3.6 environment (after many wasted hours), and I just wanted to share how I did this. I have a collaborator who is stuck on Windows, and this looks like it could be a possible solution for us.

I'm not sure if this would be worth mentioning in your documentation as an option, but maybe another user would find this information helpful.

This is a fairly ugly, so I'd be interested to hear if anyone has any cleaner ways to get this up and running.

The following are the commands I used to install this within Google Colaboratory notebook:

!apt install libboost-dev cmake cmake-curses-gui g++ python3-dev libboost-dev cmake cmake-curses-gui g++ cython3 freeglut3-dev
rm -rf /usr/include/numpy
!ln -s /usr/local/lib/python3.6/dist-packages/numpy/core/include/numpy /usr/include/numpy
!git clone https://github.com/rmcantin/bayesopt
cd bayesopt/
!cmake -DBAYESOPT_PYTHON_INTERFACE=ON -DPYTHON_LIBRARY=/usr/lib/python3.6/config-3.6m-x86_64-linux-gnu/libpython3.6m.so -DPYTHON_INCLUDE_DIR=$(python-config --prefix)/include/python3.6 -DPYTHON_NUMPY_INCLUDE_DIR=/usr/lib/python3.6/dist-packages/numpy/core/include . && make && make install
cp /usr/lib/python2.7/dist-packages/bayes* /usr/lib/python3.6/
cd python/
%run demo_distance.py

And here is a sample notebook: https://colab.research.google.com/drive/1ajWJGdrZCdfRML4O6Ltv2NpOE4w_oyFF

Very excited to optimize some functions now!

All the best, CJ

rmcantin commented 4 years ago

This is great! Thank you for the contribution!

The only think I can see to clean it up, is that you don't need the first box !apt install... . The minimal dependencies are already installed, and the others can't be used from colab or are for devs only.

I think default colabs are now python3 so it might works with the default numpy library, etc.

But it is great to know that it works!

patrickherring-TRI commented 4 years ago

Hi,

Thought I would share the snippet that I used to get this installed and running on AWS SageMaker in case it helps out someone else.

!sudo yum install -y boost-devel cmake gcc Cython freeglut-devel libXi-devel libXmu-devel python36-devel.x86_64
!sudo rm /usr/lib64/libGL.so
!sudo ln -s /usr/lib64/libGL.so.1.7.0 /usr/lib64/libGL.so
!git clone https://github.com/rmcantin/bayesopt
!cd bayesopt && cmake -DBAYESOPT_PYTHON_INTERFACE=ON && sudo make && sudo make install