Python2.7与Python3.5共存Caffe

本文介绍了如何在Ubuntu16.04系统中同时配置Python2.7的NVCaffe和Python3.5的BVLC Caffe,包括修改Makefile.config,解决protobuf动态库冲突问题,以及确保每个Python版本能正确导入对应的Caffe库。详细步骤包括注释Python Include,静态编译protobuf等。

先简单说一下我的环境:

我用的是Ubuntu16.04,电脑中有两个版本的Caffe,分别是NVCaffe-0.17-dev与BVLC Caffe 1.0版本。由于工作需要,两个版本的caffe都要用,因此想要尝试在Python2.7中使用NVCaffe,在Python3.5中使用BVLC Caffe。电脑装有CUDA9.0+CUDNNv7,显卡为GTX1080。经过一番折腾终于搞定,记录下来以备不时之需。

Python2.7下安装NVCaffe

NVCaffe的安装与正常安装一样,默认安装在Python2.7中,只需要按照自己的需要更改下Makefile.config即可,我的Makefile.config如下:

## Refer to http://caffe.berkeleyvision.org/installation.html
# Contributions simplifying and improving our build system are welcome!

# cuDNN acceleration switch (uncomment to build with cuDNN).
# cuDNN version 6 or higher is required.
USE_CUDNN := 1

# NCCL acceleration switch (uncomment to build with NCCL)
# See https://github.com/NVIDIA/nccl
# USE_NCCL := 1

# Builds tests with 16 bit float support in addition to 32 and 64 bit.
#TEST_FP16 := 1

# uncomment to disable IO dependencies and corresponding data layers
# USE_OPENCV := 0
# USE_LEVELDB := 0
# USE_LMDB := 0

# Uncomment if you're using OpenCV 3
#OPENCV_VERSION := 3

# To customize your choice of compiler, uncomment and set the following.
# N.B. the default for Linux is g++ and the default for OSX is clang++
# CUSTOM_CXX := g++

# CUDA directory contains bin/ and lib/ directories that we need.
CUDA_DIR := /usr/local/cuda
# On Ubuntu 14.04, if cuda tools are installed via
# "sudo apt-get install nvidia-cuda-toolkit" then use this instead:
# CUDA_DIR := /usr

# CUDA architecture setting: going with all of them.
CUDA_ARCH := 	\
		-gencode arch=compute_61,code=sm_61 \
		-gencode arch=compute_61,code=compute_61

# BLAS choice:
# atlas for ATLAS
# mkl for MKL
# open for OpenBlas - default, see https://github.com/xianyi/OpenBLAS
BLAS := open
# Custom (MKL/ATLAS/OpenBLAS) include and lib directories.
#BLAS_INCLUDE := /opt/OpenBLAS/include/
#BLAS_LIB := /opt/OpenBLAS/lib/

# Homebrew puts openblas in a directory that is not on the standard search path
# BLAS_INCLUDE := $(shell brew --prefix openblas)/include
# BLAS_LIB := $(shell brew --prefix openblas)/lib

# This is required only if you will compile the matlab interface.
# MATLAB directory should contain the mex binary in /bin.
# MATLAB_DIR := /usr/local
# MATLAB_DIR := /Applications/MATLAB_R2012b.app

# NOTE: this is required only if you will compile the python interface.
# We need to be able to find Python.h and numpy/arrayobject.h.
PYTHON_INCLUDE := /usr/include/python2.7 \
		/usr/local/lib/python2.7/dist-packages/numpy/core/include
# Anaconda Python distribution is quite popular. Include path:
# Verify anaconda location, sometimes it's in root.
# ANACONDA_HOME := $(HOME)/anaconda
# PYTHON_INCLUDE := $(ANACONDA_HOME)/include \
		# $(ANACONDA_HOME)/include/python2.7 \
		# $(ANACONDA_HOME)/lib/python2.7/site-packages/numpy/core/include \

# Uncomment to use Python 3 (default is Python 2)
#PYTHON_LIBRARIES := boost_python3 python3.5m
#PYTHON_INCLUDE := /usr/include/python3.5m \
#                 /usr/lib/python3.5/dist-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

# Homebrew installs numpy in a no
内容概要:本文围绕基于模型预测控制(MPC)滚动时域估计(MHE)集成的目标点镇定方法展开深入研究,重点探讨其在六自由度机械臂系统中的应用,并提供了完整的Matlab代码实现。研究充分结合MPC的多步预测、滚动优化反馈校正能力,以及MHE对系统内部状态的高精度在线估计优势,构建了协同工作的闭环控制架构,实现了复杂非线性系统下对目标点的高精度、强鲁棒性镇定控制。文中系统阐述了MPC预测模型的建立、代价函数的设计、状态输入约束的处理机制,以及MHE基于优化准则进行状态估计的实现流程,详细展示了算法的整体设计思路、数值实现步骤仿真验证过程。通过仿真实验验证了该集成策略在抑制外部干扰、补偿模型不确定性方面的优越性能。此外,资源还整合了多种先进控制技术优化算法的仿真案例,涵盖机器人、电力电子、智能交通等多个领域,为科研人员提供丰富的算法复现工程参考资源。; 适合人群:具备一定控制理论基础和Matlab编程能力,从事自动化、机器人、电力电子、智能系统等相关领域的研究生、科研人员及工程技术人员。; 使用场景及目标:① 学习并掌握MPCMHE联合控制策略的设计原理代码实现方法;② 应用于机械臂、无人机、智能车辆等复杂系统的高精度运动控制状态估计任务;③ 为科研论文复现、工程项目开发及先进控制算法的优化改进提供可运行、可调试的代码基础。; 阅读建议:建议结合文中的算法理论描述Matlab代码进行同步研读,重点关注MPC中预测模型构建、权重矩阵整定、约束处理以及MHE状态估计的优化求解实现细节,鼓励在仿真环境中动手调试参数,有条件的情况下可进一步在实际物理系统或高保真模型中进行验证性能评估。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值