您的位置:首页 > 运维架构 > Linux

linux redhat7 升级NVIDIA显卡驱动步骤

2017-03-11 11:02 441 查看

1 背景

前面在redhat7服务器上升级了tensorflow1.0,发现GPU用不了

根据教程,测试GPU:

# 新建一个 graph.
import tensorflow as tf
a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a')
b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b')
c = tf.matmul(a, b)
# 新建session with log_device_placement并设置为True.
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
# 运行这个 op.
print sess.run(c)


报错:

failed call to cuInit: CUDA_ERROR_NO_DEVICE
retrieving CUDA diagnostic information for host: ml-login2


测试cuda状态:

[root@xxxx ~]# nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2016 NVIDIA Corporation
Built on Tue_Jan_10_13:22:03_CST_2017
Cuda compilation tools, release 8.0, V8.0.61


测试GPU:

% nvidia-smi
报错:
Failed to initialize NVML: Driver/library version mismatch


注:nvidia-smi(The Nvidia System Management Interface)是Nvidia显卡命令行管理套件,基于NVML(Nvidia Management Library)库,旨在管理和监控Nvidia GPU设备

查了半天,确定是要更新nvidia driver

2 更新步骤

可以看:

http://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#handle-uninstallation

2.1 关闭Nouveau

2.1.1 linux默认安装的是nouveau的显卡驱动,它并不属于nvidia驱动。 要安装nvidai驱动,需要先停止Nouveau

先检查nouveau是否运行:

$ lsmod | grep nouveau


如果有,说明nouveau在运行,需要停止:

2.1.2. 在 /etc/modprobe.d/blacklist-nouveau.conf 文件中加入一下两行:

blacklist nouveau
options nouveau modeset=0


2. 重新生成kernel initramfs

$ sudo dracut --force


2.2 下载驱动文件

在官网下载合适的驱动文件

http://www.nvidia.cn/Download/index.aspx?lang=cn

我下的是 NVIDIA-Linux-x86_64-375.39.run

2.3 关于文本模式

升级显卡驱动,需要从窗口模式进入文本模式(即命令行模式)。 因为阿里云hpc本身就是在文本模式下,所以不需要设置。

可以通过以下方式查看centOS7 (包括redhat7)当前模式:

$ ll /etc/systemd/system/default.target
systemctl set-default multi-user.target  表明是文本模式
systemctl set-default graphical.target   表明是窗口模


需要设置的话,参考http://www.cnblogs.com/lanston/p/3880577.html

2.4 执行安装文件

$ sh NVIDIA-Linux-x86_64-375.39.run


过程中需要选择一些选项(已经不记得了)。

最后

$ reboot


DONE!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息