ubuntu18.04 cuda8.0 cudnn5 caffe python2.7 install

Posted Sun7_She

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ubuntu18.04 cuda8.0 cudnn5 caffe python2.7 install相关的知识,希望对你有一定的参考价值。

1. prepare

sudo apt install vim

sudo vim /etc/apt/sources.list

ubuntu镜像-ubuntu下载地址-ubuntu安装教程-阿里巴巴开源镜像站

sudo apt-get update

sudo apt-get upgrade

sudo apt install python

2. install opencv

其实opencv只用一句话来装就可以

sudo apt install libopencv-dev

但是下边的过程还是记录一下好了,第2小节之后的内容可以不看,直接跳到第3小节

linux安装opencv和Makefile:160: recipe for target 'all' failed问题解决方案_Yancy的博客-CSDN博客git clone https://github.com/Itseez/opencv.git

git clone https://github.com/Itseez/opencv_contrib.git

将opencv_contrib目录移到opencv目录下

添加需要的依赖库:

sudo apt-get install build-essential
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
 

error1:

E: Unable to locate package libjasper-dev的解决办法(亲测可以解决)_mango-CSDN博

solution1 start:

sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main"

sudo apt update

sudo apt install libjasper1 libjasper-dev

solution1 end

cd命令进入opencv

mkdir build

进入build目录,开始编译

cmake -D CMAKE_INSTALL_PREFIX=/usr/local -D CMAKE_BUILD_TYPE=Release -D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules ..

make -j8

sudo make install

cd /usr/local/lib

ls

error2:

solution2 start:

sudo make uninstall

sudo apt install libopencv-dev

solution2 end

3. install cuda8.0+cudnn5

sudo dpkg -i ...

cuda-license-8-0
cuda-misc-headers-8-0
cuda-npp-8-0
cuda-npp-dev-8-0
cuda-nvgraph-8-0
cuda-nvgraph-dev-8-0
cuda-nvml-dev-8-0
cuda-nvrtc-8-0
cuda-nvrtc-dev-8-0
libcudnn5
libcudnn5-dev
cuda-core-8-0
cuda-cublas-8-0
cuda-cublas-dev-8-0
cuda-cudart-8-0
cuda-cufft-8-0
cuda-cufft-dev-8-0
cuda-curand-8-0
cuda-curand-dev-8-0
cuda-cusolver-8-0
cuda-cusolver-dev-8-0
cuda-cusparse-8-0
cuda-cusparse-dev-8-0
cuda-driver-dev-8-0
cuda-cudart-dev-8-0
cuda-command-line-tools-8-0

error 3:

solution3 start:

sudo vim /etc/apt/sources.list

ubuntu镜像-ubuntu下载地址-ubuntu安装教程-阿里巴巴开源镜像站

sudo apt-get update

sudp apt-get upgrade

solution3 end

sudo ubuntu-drivers autoinstall

4. install caffe & test code

sudo apt-get install git

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 libatlas-base-dev

sudo apt-get install python-dev

sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev

cd /home/ruoqi256/srq/model

git clone https://github.com/Eniac-Xie/faster-rcnn-resnet.git

git clone https://github.com/Eniac-Xie/caffe-fast-rcnn.git

cp -r caffe-fast-rcnn faster-rcnn-resnet

cd faster-rcnn-resnet/caffe-fast-rcnn

mv Makefile.config.example Makefile.config

sudo apt-get install python-setuptools

sudo apt install python-pip

pip install cython

//-----------------------------------------------------------------------------
vim Makefile.config

opencv_vertion := 3

CUDA_DIR := /usr/local/cuda-8.0

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_60,code=sm_60 \\
                -gencode arch=compute_61,code=sm_61 \\
                -gencode arch=compute_61,code=compute_61

WITH_PYTHON_LAYER := 1

vim Makefile.config

change

CUDA_DIR := /usr/local/cuda-8.0

change

# 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

//-----------------------------------------------------------------------------

mkdir build

cd build

sudo apt-get install the python-dev

sudo apt-get install python-scipy

sudo apt-get install python-numpy

sudo apt install cmake

cmake ..

make

make install

~/.bashrc ---->

export PYTHONPATH=~/srq/model/faster-rcnn-resnet/caffe-fast-rcnn/python:$PYTHONPATH

terminal write export PYTHONPATH=~/srq/model/faster-rcnn-resnet/caffe-fast-rcnn/python:$PYTHONPATH

over

error4: nvidia-smi 无法使用

solution4 start:

E: 无法定位软件包:nvidia-470(核显+独显安装ubuntu操作说明)_znevegiveup1的博客-CSDN博客s

solution4 end

error5:

solution5 start:

sudo apt install nvidia-cuda-toolkit

solution5 end

error6:

 solution6 start:

change setup.py

'lib64': pjoin(home, 'lib64') -------->'lib64': pjoin(home, 'lib')

solution6 end

error7:

solution7 start:

sudo apt-get install  protobuf-compiler

solution7 end

error8

 编译caffe出现:src/caffe/net.cpp:9:18: fatal error: hdf5.h: No such file or directory compilation termina

编译caffe出现:src/caffe/net.cpp:9:18: fatal error: hdf5.h: No such file or directory compilation termina_nanxiaoting的博客-CSDN博客

solution8 start:

修改Makefile.config文件中这两行,改成:

# 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 /usr/lib/x86_64-linux-gnu/hdf5/serial
solution8 end

error9:

 solution9 start:

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

solution9 end

error10 :

solution10 start:

Makefile.config

CUDA_DIR := /usr/local/cuda-8.0

solution10 end

error11:

error: #error -- unsupported GNU version! gcc versions later than 5 are not supported!

solution11 start:

Ubuntu 安装 gcc/g++ 5.0_HexRain的专栏-CSDN博客

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-5         
sudo apt-get install g++-5
后边这四句有点取巧了,最好还是按照对的方式安装,也可不看

sudo cp /usr/bin/gcc-5 /usr/local/cuda-8.0/bin/

sudo cp /usr/bin/g++-5 /usr/local/cuda-8.0/bin/

sudo ln -s /usr/bin/gcc-5 /usr/local/cuda-8.0/bin/gcc

sudo ln -s /usr/bin/g++-5 /usr/local/cuda-8.0/bin/g++

solution11 end

error12:

solution 12 start:

vim Makefile.config

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_50,code=compute_50

solution 12 end

sudo apt install python-pip

error13:

No package 'gstreamer-base-1.0' found 

solution13 start:

sudo apt install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev

solution13 end

 error14: sudo apt install nvidia-cuda-toolkit

解决apt-get安装中的E: Sub-process /usr/bin/dpkg returned an error code (1)问题 - orzs - 博客园

solution14 start:

cd /var/lib/dpkg/

sudo mv info/ info_bak          # 现将info文件夹更名

sudo mkdir info                     #再新建一个新的info文件夹

sudo apt-get update             #更新

sudo apt-get -f install            #修复

sudo mv info/* info_bak/       # 执行完上一步操作后会在新的info文件夹下生成一些文件,现将这些文件全部移到info_bak文件夹下

sudo rm -rf info                     # 把自己新建的info文件夹删掉

sudo mv info_bak info

solution14 end

error15 fatal error: caffe/proto/caffe.pb.h: No such file or directory_https://space.bilibili.com/59807853-CSDN博客

error16 caffe的两个重要错误_AlphaHolo的博客-CSDN博客

------------------------------------------------------------------------------------------------------------------------------

sudo apt-get install python-skimage

pip install protobuf

「Python」class DescriptorBase(metaclass=DescriptorMetaclass)_Liiipseoroinis-CSDN博客

最后,感谢王凌宇老师的指导,我才可以完成这复杂(对于我来说)的环境配置任务~

以上是关于ubuntu18.04 cuda8.0 cudnn5 caffe python2.7 install的主要内容,如果未能解决你的问题,请参考以下文章

ubuntu18.04 cuda8.0 cudnn5 caffe python2.7 install

ubuntu18.04 cuda8.0 cudnn5 caffe python2.7 install

GTX 1080+Ubuntu16.04+CUDA8.0+cuDNN5.0+TensorFlow

深度学习环境搭建:Tensorflow1.4.0+Ubuntu16.04+Python3.5+Cuda8.0+Cudnn6.0

Ubuntu16.04 +cuda8.0+cudnn+caffe+theano+tensorflow配置明细

ubuntu16.04+cuda8.0+cudnn5.0+caffe