ubuntu18.04安装cuda10和cudnn7.5

ubuntu18.04部署cuda 10和cudnn 7.5

cuda安装:

  • 先按照正确方法安装上显卡驱动(cuda版本和显卡驱动要在官网进行确定)
  • 去这个网站下载cuda https://developer.nvidia.com/cuda-toolkit-archive
  • 选择linux->x86_64->Ubuntu->18.04->run file(local) 进行下载
  • 在服务器执行这个程序,按照提示安装,注意不要安装显卡驱动就好了

cudnn安装:

  • 注册nvidia的开发者账号

  • 在这个页面 https://developer.nvidia.com/rdp/cudnn-download 下载cudnn7.6

  • 此时会下载一个tgz压缩包

  • 在服务器中

    1
    2
    tar zxvf cudnn-10.0-linux-x64-v7.5.0.56.tgz
    cp cuda/* /usr/local/cuda-10.0 -r
  • 复制过去后,已经完成cudnn库的安装

环境变量的设定

  • /etc/profile 以及自己的bashrc中(~/.bashrc或者~/.zshrc)加入以下信息

    1
    2
    3
    4
    export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
    export PATH=/usr/local/cuda/bin:$PATH
    export LD_PRELOAD=/lib/x86_64-linux-gnu/librt.so.1
  • 重启服务器

测试

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# yewei @ DI-ROG in ~ [16:15:21]
$ python3
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> tf.Session()
2019-04-12 16:15:27.733171: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2019-04-12 16:15:27.800581: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:998] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2019-04-12 16:15:27.801337: I tensorflow/compiler/xla/service/service.cc:150] XLA service 0x1ae2960 executing computations on platform CUDA. Devices:
2019-04-12 16:15:27.801356: I tensorflow/compiler/xla/service/service.cc:158] StreamExecutor device (0): GeForce GTX 1070, Compute Capability 6.1
2019-04-12 16:15:27.821878: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 2808000000 Hz
2019-04-12 16:15:27.822543: I tensorflow/compiler/xla/service/service.cc:150] XLA service 0x21a6e90 executing computations on platform Host. Devices:
2019-04-12 16:15:27.822565: I tensorflow/compiler/xla/service/service.cc:158] StreamExecutor device (0): <undefined>, <undefined>
2019-04-12 16:15:27.822785: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1433] Found device 0 with properties:
name: GeForce GTX 1070 major: 6 minor: 1 memoryClockRate(GHz): 1.645
pciBusID: 0000:01:00.0
totalMemory: 7.93GiB freeMemory: 138.88MiB
2019-04-12 16:15:27.822800: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1512] Adding visible gpu devices: 0
2019-04-12 16:15:27.823532: I tensorflow/core/common_runtime/gpu/gpu_device.cc:984] Device interconnect StreamExecutor with strength 1 edge matrix:
2019-04-12 16:15:27.823543: I tensorflow/core/common_runtime/gpu/gpu_device.cc:990] 0
2019-04-12 16:15:27.823547: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1003] 0: N
2019-04-12 16:15:27.823678: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 138 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1070, pci bus id: 0000:01:00.0, compute capability: 6.1)
<tensorflow.python.client.session.Session object at 0x7f94f9a04b00>
>>>

证明cuda和cudnn正常安装

生活再忙,也不要忘记生活原本简单的样子
0%