我是在公司1080Ti的服务器上配置的
先屏蔽掉 nouveau
vim /etc/modprobe.d/blacklist.conf
#在最后添加 blacklist nouveau
更新内核
sudo update-initramfs -u
去nvidia官网下载自己电脑对应的驱动
然后关掉图形界面
sudo service lightdm stop
cd 到你驱动下载的那个文件夹,给予驱动运行的权限
sudo chmod a+x NVIDIA-Linux-x86_64-418.56.run
运行驱动
sudo ./NVIDIA-Linux-x86_64-418.56.run --no-opengl-files
开启图形界面,然后重启
sudo service lightdm stop
如果出现啥子错误,sudo apt-get install nvidia-384然后重启,可能会无限登录,百度一下怎么解决,然后卸载驱动,再重新开始安装。
2.0 gcc降级
因为cuda9.0对应的gcc不能大于6.0,所以如果gcc大于6.0就需要进行降级
gcc -v #查看gcc版本
##安装gcc
sudo apt install gcc-5
sudo apt install g++-5
##建立新的软连接
cd /usr/bin
sudo mv gcc gcc.bak #备份
sudo ln -s gcc-5 gcc #重新链接gcc
sudo mv g++ g++.bak #备份
sudo ln -s g++-5 g++ #重新链接g++
gcc -v #查看有没有成功降级
2.1 到官网下载cuda-9.0和cudnn7.5.0
cuda
选择对应的cuda的版本
cudnn
2.2 需要你注册一个账号才能下载
2.3 安装cuda的相关依赖
sudo apt-get install freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libgl1-mesa-glx libglu1-mesa libglu1-mesa-dev
2.4 移动到下载cuda-9.0的位置,安装cuda-9.0
sudo sh cuda_9.0.176_384.81_linux.run
Do you accept the previously read EULA?
accept/decline/quit: accept
Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 367.48?
(y)es/(n)o/(q)uit: n
Install the CUDA 9.0 Toolkit?
(y)es/(n)o/(q)uit: y
Enter Toolkit Location
[ default is /usr/local/cuda-9.0 ]:
Do you want to install a symbolic link at /usr/local/cuda?
(y)es/(n)o/(q)uit: y
Install the CUDA 9.0 Samples?
(y)es/(n)o/(q)uit: n
出现这样子的情况说明安装成功
Installing the CUDA Toolkit in /usr/local/cuda-9.0 …
Installing the CUDA Samples in /home/textminer …
Copying samples to /home/textminer/NVIDIA_CUDA-9.0_Samples now…
Finished copying samples.
===========
= Summary =
===========
Driver: Not Selected
Toolkit: Installed in /usr/local/cuda-9.0
Samples: Not Selected
Please make sure that
– PATH includes /usr/local/cuda-9.0/bin
– LD_LIBRARY_PATH includes /usr/local/cuda-9.0/lib64, or, add /usr/local/cuda-9.0/lib64 to /etc/ld.so.conf and run ldconfig as root
To uninstall the CUDA Toolkit, run the uninstall script in /usr/local/cuda-9.0/bin
Please see CUDA_Installation_Guide_Linux.pdf in /usr/local/cuda-9.0/doc/pdf for detailed information on setting up CUDA.
***WARNING: Incomplete installation! This installation did not install the CUDA Driver. A driver of version at least 361.00 is required for CUDA 9.0 functionality to work.
To install the driver using this installer, run the following command, replacing with the name of this run file:
sudo .run -silent -driver
Logfile is /tmp/cuda_install_6583.log
2.5 配置环境变量
echo 'export PATH=/usr/local/cuda-9.0/bin:$PATH' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc
source ~/.bashrc
2.6 安装cudnn
解压他
sudo tar -xzvf cudnn-9.0-linux-x64-v7.5.tgz
把cudnn.h和libcudnn*放到cuda安装目录里面去
sudo cp cuda/include/cudnn.h /usr/local/cuda/include/
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64/
sudo chmod a+r /usr/local/cuda/include/cudnn.h
sudo chmod a+r /usr/local/cuda/lib64/libcudnn*
参考大佬的博客
https://blog.csdn.net/cocoaqin/article/details/78163171
4.1安装相关的依赖库
sudo apt-get --assume-yes install build-essential
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 libopenblas-dev liblapack-dev libatlas-base-dev
sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
# Python libs
sudo -H pip install --upgrade numpy protobuf
4.2 下载caffe
git clone https://github.com/BVLC/caffe.git
4.3 复制Makefile
sudo cp Makefile.config.example Makefile.config
4.4 修改Makefile.config
sudo vim Makefile.config
...
将
#USE_CUDNN := 1
修改成:
USE_CUDNN := 1
...
...
#如果此处是OpenCV2,则不用修改
将
#OPENCV_VERSION := 3
修改为:
OPENCV_VERSION := 3
...
...
将
#WITH_PYTHON_LAYER := 1
修改为
WITH_PYTHON_LAYER := 1
...
...
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib
修改为:
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
...
...
将
CUDA_ARCH := -gencode arch=compute_20,code=sm_20 \
-gencode arch=compute_20,code=sm_21 \
-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
修改为 (cuda8不需要改这个)
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
...
4.5 修改Makefile文件
sudo vim Makefile
...
将:
NVCCFLAGS +=-ccbin=$(CXX) -Xcompiler-fPIC $(COMMON_FLAGS)
替换为:
NVCCFLAGS += -D_FORCE_INLINES -ccbin=$(CXX) -Xcompiler -fPIC $(COMMON_FLAGS)
...
...
将:
LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_hl hdf5
改为:
LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_serial_hl hdf5_serial
...
4.6 在caffe目录下执行
sudo make all -j
4.7 结束后测试
sudo make runtest -j
看到左边是绿绿的,没有报错就说明成功了
5.1 安装cmake-gui
sudo apt install cmake-gui
5.2 下载openpose
git clone https://github.com/CMU-Perceptual-Computing-Lab/openpose.git
注意:git下来的openpose文件夹下的 3rdparty/caffe 和 3rdparty/pybind11 可能是空的,我是到github的openpose下另外下载然后复制过去的
5.3 下载openpose的model
cd openpose
cd models
./getModels.sh
cd ..
5.4 用CMake生成build文件
打开cmake ,选择openpose源码目录和build,如果没有build没事,他会弹出一个窗口,点yes会帮你创建
点Configure摁钮,选择Unix Makefile和use default native compling,然后点finish
然后改一下红框里的路径,如果需要pythonAPI要把第一个打勾
点击Generate按钮,没有报错就说明成功了
5.5 build
cd openpose/build/
sudo make
sudo make install
出现cannot find #include “caffe/proto/caffe.pb.h”
解决:
protoc src/caffe/proto/caffe.proto --cpp_out=.
mkdir include/caffe/proto
mv src/caffe/proto/caffe.pb.h include/caffe/proto
5.6 测试
./build/examples/openpose/openpose.bin --video examples/media/video.avi
弹出一个页面有显示人的骨架就说明安装成功