caffe compilation memo

本文详细介绍了在Ubuntu上从源代码安装Caffe深度学习框架的步骤,包括安装NCCL、CuDNN、依赖库及配置Anaconda环境,适用于Bottom-Up Attention模型的搭建。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Compile caffe from source for bottom-up

NCCL (nvidia.com has been blocked ? download local installer then apt update to install)

# https://docs.nvidia.com/deeplearning/sdk/nccl-install-guide/index.html
# download local installer  https://developer.nvidia.com/nccl
sudo dpkg -i *.deb
sudo apt update
sudo apt install libnccl2 libnccl-dev

CuDNN

# download "cudnn library for linux"
tar xfv cudnn-10.0-linux-x64-v7.6.4.38.tgz
sudo cp cuda/include/* /usr/local/cuda/include
sudo cp cuda/lib64/* /usr/local/cuda/lib64

Dependencies

  • The following steps are for ubuntu==16.04.
  • For ubuntu>=17.04 , try sudo apt build-dep caffe-cuda to install dependencies)
sudo apt-get install libopenblas-dev # OpenBLAS

sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler
sudo apt-get install — no-install-recommends libboost-all-dev
sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
sudo pip install protobuf
sudo apt-get install the python-dev

For bottom-up-attention

conda create -n py2caffe python=2.7 pip cython hdf5 pandas pyyaml
conda activate py2caffe
pip install protobuf json_lines jsonlines  # vilbert
pip install easydict opencv-python scikit-image 
cd bottom-up-attention/lib
make
cd ../caffe
make -j24 && make pycaffe

Make

cd ../caffe
cp Makefile.config.example Makefile.config

Make the following changes in Makefile.config file

WITH_PYTHON_LAYER := 1

# cuDNN acceleration switch (uncomment to build with cuDNN).
USE_CUDNN := 1

CUDA_ARCH := -gencode arch=compute_61,code=sm_61 # GeForce GTX 1080 (Ti) , check out https://developer.nvidia.com/cuda-gpus to find compute capability
BLAS := open  # OpenBLAS is faster
ANACONDA_HOME := $(HOME)/anaconda3/envs/py2bottom
# Uncomment to use Python 3 (default is Python 2)
PYTHON_LIBRARIES := boost_python3 python3.7m
PYTHON_INCLUDE := $(ANACONDA_HOME)/include/python3.7m \
                  $(ANACONDA_HOME)/lib/python3.7/site-packages/numpy/core/include

# We need to be able to find libpythonX.X.so or .dylib.
# PYTHON_LIB := /usr/lib
PYTHON_LIB := $(ANACONDA_HOME)/lib

# Whatever else you find you need goes here.
INCLUDE_DIRS := $(PYTHON_INCLUDE) $(ANACONDA_HOME)/pkgs/hdf5-1.10.4-hb1b8bf9_0/include /usr/local/include /usr/local/include /usr/include/hdf5/serial
LIBRARY_DIRS := $(PYTHON_LIB) $(ANACONDA_HOME)/pkgs/hdf5-1.10.4-hb1b8bf9_0/lib /usr/local/lib /usr/lib usr/lib/x86_64-linux-gnu/hdf5/serial

USE_NCCL := 1

Make to run test

make all -j24
make test
make runtest

Reference:

https://medium.com/@atinesh/caffe-installation-on-ubuntu-18-04-lts-python-2-7-8e8c388ce51f

https://caffe.berkeleyvision.org/installation.html#compilation

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值