Skip to content

Instantly share code, notes, and snippets.

@rsp9u
Created June 25, 2020 18:21
Show Gist options
  • Save rsp9u/c491dec0c081392ef51650da55198926 to your computer and use it in GitHub Desktop.
Save rsp9u/c491dec0c081392ef51650da55198926 to your computer and use it in GitHub Desktop.
Source build faiss-cpu without avx
FROM centos:7
RUN yum groupinstall -y "Development tools"
WORKDIR /src
RUN git clone https://github.com/kyamagu/faiss-wheels.git &&\
cd faiss-wheels &&\
git submodule init &&\
git submodule update
RUN yum install -y wget pcre pcre-devel &&\
wget https://downloads.sourceforge.net/swig/swig-4.0.1.tar.gz &&\
tar zxf swig-4.0.1.tar.gz &&\
cd swig-4.0.1 &&\
./configure --prefix=/usr --without-maximum-compile-warnings &&\
make &&\
make install
RUN yum install -y zlib-devel libffi-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel libuuid-devel xz-devel &&\
git clone git://github.com/yyuu/pyenv.git /opt/pyenv &&\
echo 'export PYENV_ROOT="/opt/pyenv"' >> /root/.bashrc &&\
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> /root/.bashrc &&\
echo 'eval "$(pyenv init -)"' >> /root/.bashrc
RUN source /root/.bashrc &&\
pyenv install 3.7-dev &&\
pyenv global 3.7-dev
RUN source /root/.bashrc &&\
yum install -y epel-release &&\
yum install -y openblas-devel lapack-devel &&\
pip install j2cli &&\
cd faiss-wheels &&\
j2 setup.py --undefined > faiss/setup.py &&\
sed -i faiss/setup.py -e "s/, '-mavx2'//g" &&\
mv faiss/python/swigfaiss.{swig,i} &&\
mv faiss/python/{faiss.py,__init__.py} &&\
cd faiss &&\
./configure --without-cuda && make && make install &&\
pip install numpy==1.15.0 wheel &&\
python setup.py build &&\
python setup.py bdist_wheel
FROM centos:7
RUN yum install -y git zlib-devel libffi-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel libuuid-devel xz-devel &&\
yum groupinstall -y "Development tools" &&\
git clone git://github.com/yyuu/pyenv.git /opt/pyenv &&\
echo 'export PYENV_ROOT="/opt/pyenv"' >> /root/.bashrc &&\
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> /root/.bashrc &&\
echo 'eval "$(pyenv init -)"' >> /root/.bashrc
RUN source /root/.bashrc &&\
pyenv install 3.7-dev &&\
pyenv global 3.7-dev
COPY --from=0 /src/faiss-wheels/faiss/dist/faiss_cpu-1.6.3-cp37-cp37m-linux_x86_64.whl .
COPY --from=0 /src/faiss-wheels/faiss/libfaiss.so /usr/local/lib/
RUN source /root/.bashrc &&\
echo "/usr/local/lib" > /etc/ld.so.conf.d/local.conf &&\
ldconfig &&\
pip install faiss_cpu-1.6.3-cp37-cp37m-linux_x86_64.whl
RUN yum install -y epel-release &&\
yum install -y openblas-serial
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment