使用docker(非Nvidia-docker)在基於CentOS image的容器中測試cuda
1,找到宿主機的nvidia驅動設備
gemfield@ai:~$ ls -la /dev | grep nvidiacrw-rw-rw- 1 root root 195, 0 10月 27 13:31 nvidia0crw-rw-rw- 1 root root 195, 1 10月 27 13:31 nvidia1crw-rw-rw- 1 root root 195, 255 10月 27 13:31 nvidiactlcrw-rw-rw- 1 root root 195, 254 10月 27 13:31 nvidia-modesetcrw-rw-rw- 1 root root 240, 0 10月 27 13:31 nvidia-uvmcrw-rw-rw- 1 root root 240, 1 10月 27 13:31 nvidia-uvm-tools
2,起docker並掛載nvidia驅動設備
gemfield@ai:~$ docker run -itd --name centos -v nvidia_driver_384.90:/usr/local/nvidia:ro --device /dev/nvidia0:/dev/nvidia0 --device /dev/nvidiactl:/dev/nvidiactl --device /dev/nvidia-uvm:/dev/nvidia-uvm --device /dev/nvidia1:/dev/nvidia1 --device /dev/nvidia-uvm-tools:/dev/nvidia-uvm-tools gemfield/centos:7.3 bash
3,在docker容器中安裝gcc c++編譯器
[root@db041e9301af /]# yum install gcc gcc-c++
4,安裝bzip2,為了Anaconda
[root@db041e9301af ~]# yum install bzip2.x86_64
5,安裝外部源用來安裝nvidia需要的商業驅動
[root@db041e9301af ~]# yum install epel-release[root@db041e9301af ~]# yum install dkms
6, 下載cuda
#cuda 8.0[root@db041e9301af ~]# wget https://developer.nvidia.com/compute/cuda/8.0/prod/local_installers/cuda-repo-rhel7-8-0-local-8.0.44-1.x86_64-rpm
7,安裝cuda
[root@db041e9301af ~]# rpm -i cuda-repo-rhel7-8-0-local-8.0.44-1.x86_64-rpm[root@db041e9301af ~]# yum clean all[root@db041e9301af ~]# yum install cuda
8, 安裝ffmpeg
rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.rorpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpmyum install ffmpeg ffmpeg-devel -y
9,安裝gtk
yum install gtk+-devel gtk2-devel
10,編譯opencv
yum install cmakerm -f /usr/bin/pythonln -s /opt/tool/anaconda3/bin/python /usr/bin/pythoncmake -DWITH_CUDA=off -DCMAKE_INSTALL_PREFIX=/opt/tool/gemfield/opencv/ -DPYTHON_INCLUDE_DIR=$(python -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") -DPYTHON_LIBRARY=$(python -c "import distutils.sysconfig as sysconfig; print(sysconfig.get_config_var(LIBDIR))") ../ 2>&1 | tee /tmp/gemfield1
11, 編譯Caffe
yum install protobuf-devel hdf5-devel leveldb-devel opencv-develyum install boost-devel gflags-devel glog-devel lmdb-develyum install atlas-devel snappy-devel#庫的版本名字似乎有變化,建立以下軟鏈接ln -s /usr/lib64/atlas/libtatlas.so /usr/lib64/atlas/libatlas.soln -s /usr/lib64/atlas/libtatlas.so /usr/lib64/atlas/libcblas.so#python庫,這個是import caffe的時候需要的pip install scikit-image numpy protobuf#這個faster-rcnn需要pip install easydictpip install pyyamlyum install tkinter
(不定期更新)
推薦閱讀:
※學習docker要有什麼基礎?
※這張圖裡的幾個動物分別是指的哪些軟體項目?
※Insta360容器化&DevOps之路
※深度調查:24%的Docker鏡像都存在嚴重漏洞
※GitLab安裝、使用教程(Docker版)
TAG:CentOS | TensorFlow | Docker |