ubuntu18.04+cuda9.0+cudnn7.1.4+caffe-ssd+anaconda2安装

几乎是小白一枚,折腾多天才搞定,参考了很多博客和社区问答,把安装经验记下来。

1.检测显卡,安装驱动

1 ~$ ubuntu-drivers devices
2 == /sys/devices/pci0000:00/0000:00:1c.4/0000:09:00.0 ==
3 modalias : pci:v000010DEd00001292sv00001028sd00000616bc03sc02i00
4 vendor : NVIDIA Corporation
5 model : GK208M [GeForce GT 740M]
6 driver : nvidia-340 - distro non-free
7 driver : nvidia-driver-390 - distro non-free recommended
8 driver : xserver-xorg-video-nouveau - distro free builtin

选择后面带recommended的驱动

1 ~$ sudo apt install nvidia-driver-390

重启,在系统设置-详细信息的图形一栏查看gpu

2.安装CUDA和cuDNN

这方面攻略很多,我就不一一写了,CUDA9.0,共5个文件。cuDNN7.1.4:

cuDNN v7.1.4 Runtime Library for Ubuntu16.04 (Deb)

cuDNN v7.1.4 Developer Library for Ubuntu16.04 (Deb)

cuDNN v7.1.4 Code Samples and User Guide for Ubuntu16.04 (Deb)

gcc、g++降级

1 sudo apt-get install gcc-4.8
2 sudo apt-get install g++-4.8

在\usr\bin下

sudo rm  g++ ##删除原链接sudo rm  gccsudo ln -s gcc-4.8 gcc ##重建链接sudo ln -s g++-4.8 g++

下载好对应版本CUDA和cuDNN安装包(此处省略)

安装CUDA

由于前面已安装好驱动,在装CUDA时不用按ctrl+alt+f3切换到命令行界面,不用输入关闭一系列xxx的命令,只需在图形界面下运行.run文件

sudo sh cuda_9.0.176_384.81_linux.run

同意协议后,问是否安装显卡驱动,填no,剩下部分填yes或回车,剩下就没什么问题了。我安装后提示缺少几个文件,有点忘了,这个百度一下就能解决。之后再安装CUDA的几个补丁。

sudo sh cuda_9.0.176.1_linux.run ##共有四个补丁,这里只列一个

最后记得在~/.bashrc里加上这两条:

export PATH="/usr/local/cuda-9.0/bin:$PATH"
export LD_LIBRARY_PATH="/usr/local/cuda-9.0/lib64:$LD_LIBRARY_PATH"

安装cuDNN(省略)

3.安装anaconda2(省略)

4.安装caffe-ssd

安装各种依赖:

在/etc/apt下打开sources.list,源代码一项打钩,然后

sudo apt build-dep caffe-cuda

再按照之前办法安装gcc5,g++5,修改链接,之后要用g++5编译caffe

git下载caffe-ssd源代码

git clone https://github.com/weiliu89/caffe.git
cd caffe
git checkout ssdcp Makefile.config.example 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).
 USE_CUDNN := 1

# CPU-only switch (uncomment to build without GPU support).
# CPU_ONLY := 1

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

# uncomment to allow MDB_NOLOCK when reading LMDB files (only if necessary)
#    You should not set this flag if you will be reading LMDBs with any
#    possibility of simultaneous read and write
 ALLOW_LMDB_NOLOCK := 1

# 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.
# For CUDA < 6.0, comment the lines after *_35 for compatibility.
 #           -gencode arch=compute_20,code=sm_20 \
 #           -gencode arch=compute_20,code=sm_21 \
CUDA_ARCH := -gencode arch=compute_30,code=sm_30              -gencode arch=compute_35,code=sm_35
#            -gencode arch=compute_50,code=sm_50 \
#            -gencode arch=compute_52,code=sm_52 \
#            -gencode arch=compute_61,code=sm_61

# BLAS choice:
# atlas for ATLAS (default)
# mkl for MKL
# open for OpenBlas
 BLAS := atlas
#BLAS := open
# Custom (MKL/ATLAS/OpenBLAS) include and lib directories.
# Leave commented to accept the defaults for your choice of BLAS
# (which should work)!
# BLAS_INCLUDE := /path/to/your/blas
# BLAS_LIB := /path/to/your/blas

# 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/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)/anaconda2
 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.6m
# PYTHON_INCLUDE := /usr/include/python3.6 \
#                 /usr/lib/python3/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 non standard path (keg only)
# PYTHON_INCLUDE += $(dir $(shell python -c ‘import numpy.core; print(numpy.core.__file__)‘))/include
# PYTHON_LIB += $(shell brew --prefix numpy)/lib

# Uncomment to support layers written in Python (will link against Python libs)
 WITH_PYTHON_LAYER := 1

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

# If Homebrew is installed at a non standard location (for example your home directory) and you use it for general dependencies
# INCLUDE_DIRS += $(shell brew --prefix)/include
# LIBRARY_DIRS += $(shell brew --prefix)/lib

# Uncomment to use `pkg-config` to specify OpenCV library paths.
# (Usually not necessary -- OpenCV libraries are normally installed in one of the above $LIBRARY_DIRS.)
# USE_PKG_CONFIG := 1

# N.B. both build and distribute dirs are cleared on `make clean`
BUILD_DIR := build
DISTRIBUTE_DIR := distribute

# Uncomment for debugging. Does not work on OSX due to https://github.com/BVLC/caffe/issues/171
# DEBUG := 1

# The ID of the GPU that ‘make runtest‘ will use to run unit tests.
TEST_GPUID := 0

# enable pretty build (comment to see full commands)
Q ?= @

安装caffe

在caffe根目录下

make -j8
make py
make test -j8
make runtest -j8

make runtest -j8如果出现这种error:

.build_release/tools/caffe: error while loading shared libraries:
libhdf5_hl.so.100: cannot open shared object file: No such file or directory

,就在.bashrc中加上:

export LD_LIBRARY_PATH="/home/.../anaconda2/lib:$LD_LIBRARY_PATH"

在caffe根目录下的:

source ~/.bashrc
make runtest -j8

应该能通过,那么caffe-ssd就安装好了。

之后如果import caffe时报错:No module named caffe,就在.bashrc文件加上:

export PYTHONPATH="/home/.../caffe/python"

如果跑代码时出现 no module named google.protobuf,用:

conda install protobuf

到这里安装就完成了。

其实我本来配置的是caffe+anaconda3,但ssd貌似是用python2写的,python3跑不起来?所以就换了anaconda2。这里也顺便说下caffe+anaconda3配置:

装好anaconda3后,caffe下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).
 USE_CUDNN := 1

# CPU-only switch (uncomment to build without GPU support).
# CPU_ONLY := 1

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

# uncomment to allow MDB_NOLOCK when reading LMDB files (only if necessary)
#    You should not set this flag if you will be reading LMDBs with any
#    possibility of simultaneous read and write
 ALLOW_LMDB_NOLOCK := 1

# 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.
# For CUDA < 6.0, comment the lines after *_35 for compatibility.
 #           -gencode arch=compute_20,code=sm_20 \
 #           -gencode arch=compute_20,code=sm_21 \
CUDA_ARCH := -gencode arch=compute_30,code=sm_30              -gencode arch=compute_35,code=sm_35
#            -gencode arch=compute_50,code=sm_50 \
#            -gencode arch=compute_52,code=sm_52 \
#            -gencode arch=compute_61,code=sm_61

# BLAS choice:
# atlas for ATLAS (default)
# mkl for MKL
# open for OpenBlas
 BLAS := atlas
#BLAS := open
# Custom (MKL/ATLAS/OpenBLAS) include and lib directories.
# Leave commented to accept the defaults for your choice of BLAS
# (which should work)!
# BLAS_INCLUDE := /path/to/your/blas
# BLAS_LIB := /path/to/your/blas

# 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/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)/anaconda3
 PYTHON_INCLUDE := $(ANACONDA_HOME)/include         $(ANACONDA_HOME)/include/python3.6m         $(ANACONDA_HOME)/lib/python3.6/site-packages/numpy/core/include
# Uncomment to use Python 3 (default is Python 2)
 PYTHON_LIBRARIES := boost_python3 python3.6m
# PYTHON_INCLUDE := /usr/include/python3.6 \
#                 /usr/lib/python3/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 non standard path (keg only)
# PYTHON_INCLUDE += $(dir $(shell python -c ‘import numpy.core; print(numpy.core.__file__)‘))/include
# PYTHON_LIB += $(shell brew --prefix numpy)/lib

# Uncomment to support layers written in Python (will link against Python libs)
 WITH_PYTHON_LAYER := 1

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

# If Homebrew is installed at a non standard location (for example your home directory) and you use it for general dependencies
# INCLUDE_DIRS += $(shell brew --prefix)/include
# LIBRARY_DIRS += $(shell brew --prefix)/lib

# Uncomment to use `pkg-config` to specify OpenCV library paths.
# (Usually not necessary -- OpenCV libraries are normally installed in one of the above $LIBRARY_DIRS.)
# USE_PKG_CONFIG := 1

# N.B. both build and distribute dirs are cleared on `make clean`
BUILD_DIR := build
DISTRIBUTE_DIR := distribute

# Uncomment for debugging. Does not work on OSX due to https://github.com/BVLC/caffe/issues/171
# DEBUG := 1

# The ID of the GPU that ‘make runtest‘ will use to run unit tests.
TEST_GPUID := 0

# enable pretty build (comment to see full commands)
Q ?= @

还是用g++5,make前,打开.bashrc,要把/home/.../anaconda/lib从LD_LIBRARY_PATH中删去。在make过程中如果有boost::xxx 未定义,去boost官网下载源码,找找相关教程编译安装好,然后在caffe根目录下:

make clean
make -j8

应该就可以了,后续如果有bug可参考前面。



原文地址:https://www.cnblogs.com/La-Terre/p/9444445.html

时间: 2024-07-30 23:08:04

ubuntu18.04+cuda9.0+cudnn7.1.4+caffe-ssd+anaconda2安装的相关文章

Ubuntu18.04 + CUDA9.0 + cuDNN7.3 + Tensorflow-gpu-1.12 + Jupyter Notebook深度学习环境配置

目录 一.Ubuntu18.04 LTS系统的安装 1. 安装文件下载 2. 制作U盘安装镜像文件 3. 开始安装 二.设置软件源的国内镜像 1. 设置方法 2.关于ubuntu镜像的小知识 三.Nvidia显卡驱动的安装 1. 首先查看显卡型号和推荐的显卡驱动 2. 安装nvidia-390版本驱动 3. 重启系统,可以查看安装是否成功 四.CUDA9.0的安装 1. CUDA版本选择 2. 安装CUDA9.0 3. 设置环境变量 五.cuDNN7.3的安装 六.Tensorflow-1.12

YOLO 训练环境搭建(Ubuntu18.04+Cuda9.0+Cudnn7.1)

1.先查看是否安装有以下组件,若有先考虑彻底删除再安装(安装严格按照下面顺序进行) 查看nvidia 版本 nvidia-smi 查看cuda 版本 cat /usr/local/cuda/version.txt 查看cudnn 版本 cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2 2.nvidia 驱动,cuda,cudnn对应关系  nvidia与cuda要求的版本对应关系: https://docs.nvidia.co

ubuntu18.04+CUDA9.0+cuDNN7.1.4+tensorflow1.9 环境搭建

1. 主机配置说明 在前几天,得知公司新采购了几台主机,所以我们组领导就向公司申请了一台回来,做数据分析. 服务器买的是惠普的主机,型号是:HP EliteDesk 800 G3.不算强劲,但用来做GPU的数据分析测试,也可以了.具体参数:CPU:i7-7700内存: 32G显卡: GTX 1070硬盘: 256 ssd + 1T自带 windows 10 64位 专业版系统 2. 更换系统 由于主机自带的是windows系统,但是我们想用 ubuntu 的系统,因此,只能先重装一下系统了.具体

Ubuntu18.04 + cuda9.0+cudnn7.0

1 cannot find Toolkit in /usr/local/cuda-8.0 2017年05月27日 17:37:33 阅读数:2754 对于新版本ubuntukylin17.04安装CUDA时出现 cannot find Toolkit in /usr/local/cuda-8.0 问题 尝试了各种方法,均不妥当...... 参考:https://devtalk.nvidia.com/default/topic/992023/install-cuda-on-debian/ 使用ap

ubuntu tensorflow install(Ubuntu16.04+CUDA9.0+cuDNN7.5+Python3.6+TensorFlow1.5)

在网上找了很多案例,踩了许多坑,感觉比较全面的是下面介绍的 http://www.cnblogs.com/xuliangxing/p/7575586.html 先说说我的步骤: 首先安装了Anacoda,因为是科学运算环境,所以先安装了最新版,所以对应的Python 3.6 安装显卡驱动:GTX950M 安装了最新的 390驱动,担心不兼容,所以都用最新的 安装cuda,这个坑最后才发现,因为安装最新的9.1版本,最后tensorflow只找9.0的文件.所以,这个地方一定要选其他release

环境配置(近期实测)——Ubuntu16.04+CUDA9.0+tensorflow-gpu填坑记

近几年深度学习在物体检测方面出现了许多基于不同框架的网络模型,不同模型需要不同的版本的Python.TensorFlow.Keras.CUDA.cuDNN以及操作系统.不得不说,要把经典物体检测网络的源码都跑通,单配置环境就要浪费很多时间,因为目前兼容这些经典网络的框架和环境还很少.新版的TensorFlow在models的objection-detection模块中包含了fast-rcnn.rfcn.SSD几种网络,不过开发环境是基于Ubuntu的,因此我对该环境进行了配置. 1.Ubuntu

TensorFlow安装(Ubuntu18.04+Anaconda3+CUDA9.0+cuDNN7.1+TensorFlow1.8.0+Pycharm)

p { margin-bottom: 0.1in; line-height: 115% } a:link { } 1.安装pip (1)安装 sudo apt-get install python3-pip python3-dev (2)查看pip是否安装成功 pip3 -V (3)切换国内源 Linux下,修改 ~/.pip/pip.conf (没有就创建一个), 修改 index-url至tuna,内容如下: [global] index-url = https://pypi.tuna.ts

anconda1.8+cuda9.0+cudnn7.0.5+tensorflow1.7(win10)安装

1.下载安装cuda9.0 https://developer.nvidia.com/cuda-90-download-archive 2.下载cudnn7.0.5,下载cuda9.0的对应版本 https://developer.nvidia.com/rdp/cudnn-download 操作: 1.将cudnn文件夹下的文件拷贝到cuda9.0对应的文件夹下 2.打开cmd,用命令nvcc -V检验cuda是否安装成功,成功界面如下: 说明:之前用的是cudnn7.1.2,一直出各种问题,最

Win10+CUDA9.0+cuDNN7.2 下载 安装 配置

安装CUDA前须安装VS2015 参考: https://blog.csdn.net/yuyushikuan/article/details/79067484 https://blog.csdn.net/fengbingchun/article/details/53892997 1.下载: CUDA9.0下载链接(1.33GB):https://developer.nvidia.com/cuda-90-download-archive?target_os=Windows&target_arch=