Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentes Révision précédente
Prochaine révision
Révision précédente
caffe_singularity [2017/07/13 12:10] – [Create the image] admincaffe_singularity [2017/07/13 18:00] (Version actuelle) – [Install or (bootsrap) the container the image] admin
Ligne 16: Ligne 16:
 $ sudo create -size 2048 caffe-cpu.img $ sudo create -size 2048 caffe-cpu.img
 </code> </code>
 +
 +This command will create a file named ''caffe-cpu.img'' of size 2Go.
  
  
Ligne 21: Ligne 23:
  
 ===== Install or (bootsrap) the container the image ===== ===== Install or (bootsrap) the container the image =====
 +
 +Next, we need install system (ubuntu), all required softwares and finally caffe. 
 +
 +The Bootsrap file is given bellow:
 +
 +<file bash Singularity>
 +
 +BootStrap: docker
 +From: ubuntu:latest
 +
 +%setup
 +# commands to be executed on host outside container during bootstrap
 +
 +%post
 +# commands to be executed inside container during bootstrap
 +
 +# create bind points for MesoFC HPC environment
 +mkdir -p /Work
 +mkdir -p /Home
 +
 +### Install depencies applications
 +apt-get update && apt-get install -y --no-install-recommends \
 +        build-essential \
 +        cmake \
 +        git \
 +        wget \
 +        libatlas-base-dev \
 +        libboost-all-dev \
 +        libgflags-dev \
 +        libgoogle-glog-dev \
 +        libhdf5-serial-dev \
 +        libleveldb-dev \
 +        liblmdb-dev \
 +        libopencv-dev \
 +        libprotobuf-dev \
 +        libsnappy-dev \
 +        protobuf-compiler \
 +        python-dev \
 +        python-numpy \
 +        python-pip \
 +        python-setuptools \
 +        python-scipy && \
 +#rm -rf /var/lib/apt/lists/*
 +
 +### Install caffe in /opt
 +cd /opt
 +
 +git clone  https://github.com/BVLC/caffe.git  && \
 +    cd caffe && pip install --upgrade pip && \
 +    cd python && pip install -r requirements.txt&& \
 +    cd ..&&mkdir build && cd build && \
 +    cmake -DCPU_ONLY=1 .. && \
 +    make -j"$(nproc)"&&make install
 +
 +
 +### update environement variable
 +cd 
 +echo "PATH=/opt/caffe/build/install/bin:\$PATH" >> /environment
 +echo "PYTHONPATH=/opt/caffe/build/install/python:\$PYTHONPATH" >> /environment 
 +echo "LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:/opt/caffe/build/install/lib" >> /environment 
 +echo "LIBRARY_PATH=\$LIBRARY_PATH:/opt/caffe/build/install/lib" >> /environment 
 +echo "CPATH=\$CPATH:/opt/caffe/build/install/include" >> /environment  
 +echo "C_INCLUDE_PATH=\$C_INCLUDE_PATH:/opt/caffe/build/install/include" >>  /environment 
 +echo "CPLUS_INCLUDE_PATH=\$CPLUS_INCLUDE_PATH:/opt/caffe/build/install/include" >> /environment 
 +
 +echo "export PATH PYTHONPATH LD_LIBRARY_PATH LIBRARY_PATH CPATH C_INCLUDE_PATH CPLUS_INCLUDE_PATH" >> /environment 
 +ln -s /environment /.singularity.d/env/90-env.sh
 +
 +%runscript
 +# commands to be executed when the container runs
 +
 +%test
 +# commands to be executed within container at close of bootstrap process
 +
 +
 +</file>
 +
 +The command to use is:
 +
 +<code bash>
 +$ sudo singularity bootstrap caffe-cpu.img Singularity 
 +</code>
 +
 +Where 
 +  * caffe-cpu.img: the image created before
 +  * Singularity: the bootstrap file
 +
 +This will take some minutes (take a coffee).
 +
 +If all goes well, caffe is installed by success inside the container ''caffe-cpu.img'' in ''/opt/caffee'' folder. 
 +
 +
 +===== Use the container =====
 +
 +You can run caffe, in your host, inside the container:
 +
 +<code bash>
 +$ singularity exec caffe-cpu.img caffe
 +</code>
 +
 +
 +===== Use the build container on the Mesocentre =====
 +
 +Just copy this file to your cluster account (''WORK'' folder) and run singularity as usual.
 +
 +For example for interactive usage:
 +
 +<code bash>
 +$ qlogin -lh_vmem=6G
 +</code>
 +
 +
 +<code bash>
 +$ cd WORK
 +</code>
 +
 +<code bash>
 +$ module load tools/singularity
 +</code>
 +
 +
 +
 +<code bash>
 +$ singularity exec caffe-cpu.img caffe 
 +</code>
 +
 +
 +
 +====== Links ======
 +
 +  * [[caffe|Caffe Optimized for GPU]]
 +
  
  
  • caffe_singularity.1499947852.txt.gz
  • Dernière modification : 2017/07/13 12:10
  • de admin