Nvidia
开始GeForce GTX 1080 TI
410
版本的ubuntu-drivers devices
, 如下图ubuntu@ubuntu-System-Product-Name:~$ ubuntu-drivers devices
== cpu-microcode.py ==
driver : intel-microcode - distro free
== /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0 ==
vendor : NVIDIA Corporation
modalias : pci:v000010DEd00001B06sv00001458sd0000374Dbc03sc00i00
driver : nvidia-410 - third-party free recommended
driver : nvidia-384 - distro non-free
driver : xserver-xorg-video-nouveau - distro free builtin
driver : nvidia-390 - third-party free
driver : nvidia-396 - third-party free
ppa
, 若是没有,可能最新的只有nvidia-384
, 但是若想安装cuda-9.0
需要大于384.81
, 不然后面安装tensorflow-gpu
之后也会报错
ppa
:
sudo add-apt-repository ppa:graphics-drivers/ppa
(注意联网,去掉代理)sudo apt update
ubuntu-drivers devices
就可以看到如上的结果sudo apt install dkms build-essential linux-headers-generic
nouveau
模块,查看:https://blog.csdn.net/u012235003/article/details/54575758sudo apt-get install linux-headers-$(uname -r)
sudo apt install nvidia-410
nvidia-smi
(wangyongzhi_ml) ubuntu@ubuntu-System-Product-Name:/usr/local/cuda-10.0/bin$ nvidia-smi
Thu Oct 25 15:49:46 2018
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 410.66 Driver Version: 410.66 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 GTX 108... Off | 00000000:01:00.0 On | N/A |
| 0% 44C P8 20W / 250W | 42MiB / 11174MiB | 0% Default |
+-------------------------------+----------------------+----------------------+
| 1 GeForce GTX 108... Off | 00000000:02:00.0 Off | N/A |
| 0% 50C P8 20W / 250W | 2MiB / 11178MiB | 0% Default |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| 0 949 G /usr/lib/xorg/Xorg 39MiB |
+-----------------------------------------------------------------------------+
cuda-9.0
, 下载chmod +x cuda_9.0.176_384.81_linux-run
sudo ./cuda_9.0.176_384.81_linux-run
vim ~/.bashrc
# cuda9.0
export PATH=/usr/local/cuda-9.0/bin/:$PATH;
export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64/:$LD_LIBRARY_PATH;
nvcc -V
V9.0.176
(wangyongzhi_ml) ubuntu@ubuntu-System-Product-Name:~/wangyongzhi/software$ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2017 NVIDIA Corporation
Built on Fri_Sep__1_21:08:03_CDT_2017
Cuda compilation tools, release 9.0, V9.0.176
Examples
, 会在 ~
文件夹下生成测试NVIDIA_CUDA-9.0_Samples
的文件cd NVIDIA_CUDA-9.0_Samples
make
NVIDIA_CUDA-9.0_Samples/bin/x86_64/linux/release
文件夹
./deviceQuery
, 可以看到类似如下信息./deviceQuery Starting...
CUDA Device Query (Runtime API) version (CUDART static linking)
Detected 2 CUDA Capable device(s)
Device 0: "GeForce GTX 1080 Ti"
CUDA Driver Version / Runtime Version 10.0 / 9.0
CUDA Capability Major/Minor version number: 6.1
Total amount of global memory: 11174 MBytes (11717181440 bytes)
(28) Multiprocessors, (128) CUDA Cores/MP: 3584 CUDA Cores
GPU Max Clock rate: 1683 MHz (1.68 GHz)
Memory Clock rate: 5505 Mhz
Memory Bus Width: 352-bit
L2 Cache Size: 2883584 bytes
Maximum Texture Dimension Size (x,y,z) 1D=(131072), 2D=(131072, 65536), 3D=(16384, 16384, 16384)
Maximum Layered 1D Texture Size, (num) layers 1D=(32768), 2048 layers
Maximum Layered 2D Texture Size, (num) layers 2D=(32768, 32768), 2048 layers
Total amount of constant memory: 65536 bytes
Total amount of shared memory per block: 49152 bytes
Total number of registers available per block: 65536
Warp size: 32
Maximum number of threads per multiprocessor: 2048
Maximum number of threads per block: 1024
cuda
对应的版本, 我的选择如下图tar -zxvf cudnn-9.0-linux-x64-v7.3.1.20.tgz
cuda
文件夹下的内容拷贝到对应的 /usr/local/cuda-9.0
文件夹下即可python3.7
版本# anaconda3
export PATH=/home/ubuntu/anaconda3/bin:$PATH
创建虚拟环境,防止污染他人使用环境
conda create -n xxx python-3.6
conda install tensorflow-gpu
测试
import tensorflow as tf
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
2018-10-25 16:25:35.683507: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1405] Found device 0 with properties:
name: GeForce GTX 1080 Ti major: 6 minor: 1 memoryClockRate(GHz): 1.683
pciBusID: 0000:01:00.0
totalMemory: 10.91GiB freeMemory: 10.72GiB
2018-10-25 16:25:35.783459: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:897] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2018-10-25 16:25:35.783843: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1405] Found device 1 with properties:
name: GeForce GTX 1080 Ti major: 6 minor: 1 memoryClockRate(GHz): 1.683
pciBusID: 0000:02:00.0
totalMemory: 10.92GiB freeMemory: 10.76GiB
2018-10-25 16:25:35.784321: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1484] Adding visible gpu devices: 0, 1
2018-10-25 16:25:36.069610: I tensorflow/core/common_runtime/gpu/gpu_device.cc:965] Device interconnect StreamExecutor with strength 1 edge matrix:
2018-10-25 16:25:36.069634: I tensorflow/core/common_runtime/gpu/gpu_device.cc:971] 0 1
2018-10-25 16:25:36.069637: I tensorflow/core/common_runtime/gpu/gpu_device.cc:984] 0: N Y
2018-10-25 16:25:36.069639: I tensorflow/core/common_runtime/gpu/gpu_device.cc:984] 1: Y N
2018-10-25 16:25:36.069852: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1097] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 10367 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1080 Ti, pci bus id: 0000:01:00.0, compute capability: 6.1)
2018-10-25 16:25:36.101498: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1097] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:1 with 10409 MB memory) -> physical GPU (device: 1, name: GeForce GTX 1080 Ti, pci bus id: 0000:02:00.0, compute capability: 6.1)
Device mapping:
/job:localhost/replica:0/task:0/device:GPU:0 -> device: 0, name: GeForce GTX 1080 Ti, pci bus id: 0000:01:00.0, compute capability: 6.1
/job:localhost/replica:0/task:0/device:GPU:1 -> device: 1, name: GeForce GTX 1080 Ti, pci bus id: 0000:02:00.0, compute capability: 6.1
2018-10-25 16:25:36.134430: I tensorflow/core/common_runtime/direct_session.cc:288] Device mapping:
/job:localhost/replica:0/task:0/device:GPU:0 -> device: 0, name: GeForce GTX 1080 Ti, pci bus id: 0000:01:00.0, compute capability: 6.1
/job:localhost/replica:0/task:0/device:GPU:1 -> device: 1, name: GeForce GTX 1080 Ti, pci bus id: 0000:02:00.0, compute capability: 6.1
cuda-9.0
会在 /usr/local/
目录下
/usr/local/cuda-9.0/
(wangyongzhi_ml) ubuntu@ubuntu-System-Product-Name:/usr/local$ ll
总用量 48
drwxr-xr-x 12 root root 4096 10月 25 14:51 ./
drwxr-xr-x 13 root root 4096 10月 25 09:39 ../
drwxr-xr-x 2 root root 4096 4月 21 2016 bin/
lrwxrwxrwx 1 root root 19 10月 25 00:41 cuda -> /usr/local/cuda-9.0/
drwxr-xr-x 19 root root 4096 10月 25 14:52 cuda-10.0/
drwxr-xr-x 18 root root 4096 10月 25 00:41 cuda-9.0/
drwxr-xr-x 2 root root 4096 4月 21 2016 etc/
drwxr-xr-x 2 root root 4096 4月 21 2016 games/
drwxr-xr-x 2 root root 4096 4月 21 2016 include/
drwxr-xr-x 4 root root 4096 4月 21 2016 lib/
lrwxrwxrwx 1 root root 9 10月 24 14:52 man -> share/man/
drwxr-xr-x 2 root root 4096 4月 21 2016 sbin/
drwxr-xr-x 8 root root 4096 4月 21 2016 share/
drwxr-xr-x 2 root root 4096 4月 21 2016 src/
cuda
其他版本,然后创建软连接指向对应的版本即可sudo rm -rf cuda
sudo ln -s /usr/local/cuda-10.0 /usr/local/cuda
https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html
https://blog.csdn.net/u012235003/article/details/54575758