參考官網(wǎng) https://github.com/NVIDIA/nvidia-docker 為什么使用nvidia-docker2 https://www./a/37002.html --------------實(shí)踐步驟如下-------------------- 一、安裝驅(qū)動(dòng)參考最新方法 https://blog.csdn.net/smcaa/article/details/86482872 sudo apt update 安裝python庫(kù) sudo apt-get install software-properties-common python-software-properties 1. 打開ubuntu的一個(gè)終端:然后輸入: $ sudo add-apt-repository ppa:graphics-drivers/ppa 然后更新源: $ sudo apt update 2.查看當(dāng)前系統(tǒng)推薦你安裝的驅(qū)動(dòng)版本 $ ubuntu-drivers devices == /sys/devices/pci0000:00/0000:00:1c.0/0000:01:00.0 == modalias : pci:v000010DEd00001D10sv000017AAsd0000225Ebc03sc02i00 vendor : NVIDIA Corporation model : GP108M [GeForce MX150] driver : nvidia-driver-410 - third-party free driver : nvidia-driver-396 - third-party free driver : nvidia-driver-390 - third-party free driver : nvidia-driver-415 - third-party free recommended driver : xserver-xorg-video-nouveau - distro free builtin 那么顯而易見,推薦我們安裝nvidia-driver-415這個(gè),那我們就安裝這個(gè)最新的 3.輸入命令: $ sudo ubuntu-drivers autoinstall 懶人操作,用這種最簡(jiǎn)單的命令,讓系統(tǒng)幫你安裝好N家驅(qū)動(dòng)所需要的所有顯卡驅(qū)動(dòng)。 4.安裝好之后,輸入命令: $ reboot 5.重啟之后,我們要檢驗(yàn)以下N家的驅(qū)動(dòng)是否安裝好,那么我們?cè)诿疃溯斎耄?/p> $ nvidia-smi 此時(shí)問題出來了,我們?cè)诮K端看到的不是驅(qū)動(dòng)和顯卡的信息,而是......... “NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.” ---------------------重啟服務(wù)器后,重試nvidia-smi查看 ~$ nvidia-smi Mon Jan 14 18:56:07 2019 +-----------------------------------------------------------------------------+ | NVIDIA-SMI 415.25 Driver Version: 415.25 CUDA Version: 10.0 | |-------------------------------+----------------------+----------------------+ | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. | |===============================+======================+======================| | 0 GeForce MX150 Off | 00000000:01:00.0 Off | N/A | | N/A 48C P0 N/A / N/A | 958MiB / 2002MiB | 3% Default | +-------------------------------+----------------------+----------------------+ +-----------------------------------------------------------------------------+ | Processes: GPU Memory | | GPU PID Type Process name Usage | |=============================================================================| | 0 1418 G /usr/lib/xorg/Xorg 81MiB | | 0 1609 G /usr/bin/gnome-shell 95MiB | | 0 2903 C /usr/bin/python3 779MiB | +-----------------------------------------------------------------------------+ 說明我們的驅(qū)動(dòng)裝好了,接下來就可以繼續(xù)遨游了。 二、安裝docker root@ssli-centos7:~$ curl -fsSL https://get. | bash -s docker --mirror Aliyun root@ssli-centos7:~$ systemctl start docker root@ssli-centos7:~$ systemctl status docker root@ssli-centos7:~$ systemctl enable docker sudo apt update 三、安裝nvidia-docker2 ubutu安裝過程---已實(shí)測(cè) 參考官網(wǎng) https://github.com/NVIDIA/nvidia-docker 安裝前,就刪除舊版本的nvidia-docker 參考https://blog.csdn.net/y19930105/article/details/80763467 四、使用支持 GPU 的映像的示例 安裝tensorflow-gpu-py3 注意是python3版本 參考官網(wǎng)https://tensorflow.google.cn/install/docker#gpu_support 1.啟動(dòng) TensorFlow Docker 容器tensorflow-gpu-py3 docker run --runtime=nvidia -it --rm tensorflow/tensorflow:latest-gpu-py3 \ python -c "import tensorflow as tf; tf.enable_eager_execution(); print(tf.reduce_sum(tf.random_normal([1000, 1000])))" 2.在配置 TensorFlow 的容器中啟動(dòng) bash shell 會(huì)話。注意啟動(dòng)時(shí)一定要使用--runtime=nvidia,要不然docker容器里找不顯卡 docker run --runtime=nvidia -it tensorflow/tensorflow:latest-gpu-py3 /bin/bash 1.進(jìn)入容器 root@iZwz9aa80jpvwyws02urj6Z:~# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 293b73e02a6d tensorflow/tensorflow:latest-gpu-py3 "/bin/bash" 2 days ago Up 2 days heuristic_liskov root@iZwz9aa80jpvwyws02urj6Z:~# docker exec -it 293b73e02a6d /bin/bash 2.查看nividia驅(qū)動(dòng) root@293b73e02a6d:/# nvcc -V ---------------------------------------------------------------------------------------------------------------------------- 注意點(diǎn):: 一.【Ubuntu】修改Ubuntu的apt-get源為國(guó)內(nèi)鏡像源的方法 https://blog.csdn.net/zgljl2012/article/details/79065174 1、原文件備份 sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak 2、編輯源列表文件 sudo vim /etc/apt/sources.list 3、將原來的列表刪除,添加如下內(nèi)容(中科大鏡像源) deb http://mirrors.ustc.edu.cn/ubuntu/ xenial main restricted universe multiverse deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-security main restricted universe multiverse deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial main restricted universe multiverse deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-security main restricted universe multiverse deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse 4、運(yùn)行sudo apt-get update 二、PIP 更換國(guó)內(nèi)安裝源 https://blog.csdn.net/yuzaipiaofei/article/details/80891108 永久修改: linux: 修改 ~/.pip/pip.conf (沒有就創(chuàng)建一個(gè)), 內(nèi)容如下: [global] index-url = https://pypi.tuna./simple 三、物體檢測(cè)時(shí)需要的安裝包 apt-get update pip install --upgrade keras 1.執(zhí)行物體檢測(cè)腳本 root@8f9e0e5631af:/home/work/recognition/keras-YOLOv3-mobilenet# python train_Mobilenet.py -h ImportError: No module named 'PIL' 2.安裝 root@8f9e0e5631af:/home/work/recognition/keras-YOLOv3-mobilenet# pip install pillow root@8f9e0e5631af:/home/work/recognition/keras-YOLOv3-mobilenet# pip install matplotlib |
|