官方安装文档:NVIDIA Driver Installation Quickstart Guide :: NVIDIA Tesla Documentation

1.查看默认显卡驱动

[root@localhost ~]# lsmod |grep nouveau
nouveau              2351104  0
mxm_wmi                16384  1 nouveau
wmi                    32768  2 mxm_wmi,nouveau
video                  49152  1 nouveau
i2c_algo_bit           16384  1 nouveau
drm_kms_helper        266240  5 drm_vram_helper,bochs_drm,nouveau
drm_ttm_helper         16384  3 drm_vram_helper,bochs_drm,nouveau
ttm                    73728  3 drm_vram_helper,drm_ttm_helper,nouveau
drm                   585728  7 drm_kms_helper,drm_vram_helper,bochs_drm,drm_ttm_helper,ttm,nouveau

2.安装依赖环境

dnf install -y tar bzip2 make automake gcc gcc-c++ pciutils elfutils-libelf-devel libglvnd-devel
dnf install -y epel-release
distribution=rhel8
ARCH=$( /bin/arch )
dnf config-manager --add-repo http://developer.download.nvidia.com/compute/cuda/repos/$distribution/${ARCH}/cuda-$distribution.repo
dnf install -y kernel-devel-$(uname -r) kernel-headers-$(uname -r)
dnf install -y kernel kernel-core kernel-modules

3.安装NVIDIA显卡驱动

dnf clean all
dnf -y module install nvidia-driver:latest-dkms

安装之后,需要重启机器,使显卡驱动生效

[root@localhost ~]# lsmod|grep nouveau
[root@localhost ~]# lsmod|grep nvidia
nvidia_drm             69632  0
nvidia_modeset       1183744  1 nvidia_drm
nvidia_uvm           1339392  0
nvidia              55173120  2 nvidia_uvm,nvidia_modeset
drm_kms_helper        266240  5 drm_vram_helper,bochs_drm,nvidia_drm
drm                   585728  8 drm_kms_helper,drm_vram_helper,bochs_drm,nvidia,drm_ttm_helper,nvidia_drm,ttm

可以看到,默认显卡驱动已经没了,换成了NVIDIA显卡驱动

查看显卡信息

[root@localhost ~]# nvidia-smi
Tue Oct 25 10:41:05 2022
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 520.61.05    Driver Version: 520.61.05    CUDA Version: 11.8     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  NVIDIA GeForce ...  Off  | 00000000:00:10.0 Off |                  N/A |
| 20%   40C    P0    N/A /  75W |      0MiB /  4096MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------++-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+

4.安装NVIDIA CUDA工具包(包含CUPTI),当前最新为11.8版本,大概下载3.8G

dnf install cuda-toolkit-11-8 -y

5.安装NVIDIA CUDNN包,当前最新为11.8版本,需下载681M

dnf install libcudnn8 -y

6.安装Python环境进行测试

dnf install python39 python39-devel -y

创建虚拟环境,安装tensorflow

python3.9 -m venv py39
source py39/bin/activate
pip install tensorflow

通过tensorflow查看可使用设备

python -c 'import tensorflow as tf;print(tf.config.experimental.list_physical_devices())'
(py39) [root@localhost ~]# python
Python 3.9.13 (main, Jun 24 2022, 15:32:51)
[GCC 8.5.0 20210514 (Red Hat 8.5.0-13)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
2022-10-25 11:39:46.930430: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2022-10-25 11:39:47.056206: E tensorflow/stream_executor/cuda/cuda_blas.cc:2981] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered
2022-10-25 11:39:47.602293: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer.so.7'; dlerror: libnvinfer.so.7: cannot open shared object file: No such file or directory
2022-10-25 11:39:47.602366: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer_plugin.so.7'; dlerror: libnvinfer_plugin.so.7: cannot open shared object file: No such file or directory
2022-10-25 11:39:47.602381: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Cannot dlopen some TensorRT libraries. If you would like to use Nvidia GPU with TensorRT, please make sure the missing libraries mentioned above are installed properly.
>>> tf.config.experimental.list_physical_devices()
2022-10-25 11:40:00.293825: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:980] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2022-10-25 11:40:00.307989: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:980] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2022-10-25 11:40:00.308201: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:980] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
[PhysicalDevice(name='/physical_device:CPU:0', device_type='CPU'), PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]

测试下GPU速度

1.打开一个窗口,输入命令,实时监控GPU信息

watch -n1 'nvidia-smi'

2.新建test.py文件,输入以下内容,然后运行

import tensorflow as tf
import timeitdef cpu_run():with tf.device('/cpu:0'):cpu_a = tf.random.normal([10000, 1000])cpu_b = tf.random.normal([1000, 2000])c = tf.matmul(cpu_a, cpu_b)return cdef gpu_run():with tf.device('/gpu:0'):gpu_a = tf.random.normal([10000, 1000])gpu_b = tf.random.normal([1000, 2000])c = tf.matmul(gpu_a, gpu_b)return ccpu_time = timeit.timeit(cpu_run, number=10)
gpu_time = timeit.timeit(gpu_run, number=10)
print("cpu:", cpu_time, "  gpu:", gpu_time)
python test.py

centos8安装NVIDIA显卡驱动,运行机器学习代码相关推荐

  1. CentOS8安装NVIDIA显卡驱动、CUDA和Anaconda

    CentOS8安装NVIDIA显卡驱动.CUDA和Anaconda 参考:CentOS nvidia+cuda+cudnn 安装 安装英伟达显卡驱动 1.检查是否安装了NVIDIA的GPU(硬件层面) ...

  2. centos8 安装nvidia 显卡驱动(一路踩坑一路填)

    最近在安装centos8的nvidia显卡驱动,遇到了一些问题,希望能在大家的帮助下共同解决.共同学习.废话不多说,直接上内容 1 首先确认内核版本和发行版本,再确认显卡型号 (1)uname -a ...

  3. centos8安装NVIDIA显卡驱动,docker模式运行机器学习

    1.下载驱动 a.查看显卡版本,版本是1050Ti,需要在官网下载该型号驱动 [root@localhost ~]# lspci|grep -i nvidia 00:10.0 VGA compatib ...

  4. Centos8 安装NVIDIA显卡驱动

    <1>kernel-devel yum install kernel-devel <2>elfutils-libelf-devel yum install elfutils-l ...

  5. ubuntu18.04安装Nvidia显卡驱动后黑屏及网络、蓝牙驱动消失的解决方案

    ubuntu18.04安装Nvidia显卡驱动后黑屏及网络.蓝牙驱动消失的解决方案 文章目录 ubuntu18.04安装Nvidia显卡驱动后黑屏及网络.蓝牙驱动消失的解决方案 1.问题描述 2.解决 ...

  6. 安装ubuntu 16.04 + ppa安装NVIDIA显卡驱动

    (1)制作ubuntu 16.04 系统启动盘 首先从ubuntu官网根据自己系统的配置下载旧版16.04的系统镜像,选择下载64位镜像. ubuntu下载链接 将下载好的iso文件右击用压缩文件解压 ...

  7. Linux 桌面玩家指南:11. 在同一个硬盘上安装多个 Linux 发行版以及为 Linux 安装 Nvidia 显卡驱动...

    Linux 桌面玩家指南:11. 在同一个硬盘上安装多个 Linux 发行版以及为 Linux 安装 Nvidia 显卡驱动 原文:Linux 桌面玩家指南:11. 在同一个硬盘上安装多个 Linux ...

  8. Ubuntu 20.04 LTS 系统下 安装Nvidia 显卡驱动、CUDA、cuDNN, 并可进行CUDA版本切换

    因为做深度学习的研究项目,为全新机器在Ubuntu 20.04 LTS 系统下 安装Nvidia 显卡驱动.Cuda.Cudnn.并进行CUDA版本切换 成功安装完成了,写个记录. 1. 安装Nvid ...

  9. CentOS7(64位)安装NVIDIA显卡驱动和CUDA8.0

    硬件环境: 显卡驱动下载:http://www.geforce.cn/drivers点击打开链接 CUDA下载:https://developer.nvidia.com/cuda-downloads点 ...

最新文章

  1. scrum看板工具做问题跟踪
  2. linux软中断的实现
  3. 中职计算机说课稿三篇,2020精选中职计算机说课稿3篇(15页)-原创力文档
  4. Github|类别不平衡学习资源(下)
  5. A站有一个页面需要PV统计 A站读写该数据 B站读该数据 需要数据同步
  6. SQL Server 数据库中的几个常见的临界值
  7. Java与C语言混合编程
  8. Mongodb入门安装
  9. linux怎么变成windows,如何把Ubuntu 18.04改造成Windows主题界面
  10. js 中实现 汉字按拼音排序
  11. 流媒体传输协议浅析(三)可靠UDP传输方案
  12. DF-1015 DTU对接百度云天工物联网平台开发指南
  13. Word另存为PDF后无导航栏解决办法
  14. 周董演唱会为什么总是抢不到票?教你用Python做一个自动抢票脚本
  15. 线性代数笔记12——列空间和零空间
  16. T100——错误信息提示传入参数显示
  17. 北理计算机专业如何,2019北理计算机学硕经验分享
  18. 计算机C盘空间减少,为什么我电脑C盘的空间会自己在慢慢减小????
  19. python单词怎么读-python单词如何读
  20. ocr 图像倾斜矫正-霍夫变换

热门文章

  1. 一文读懂激光雷达传感器及其核心指标
  2. 地平线4卡在转圈界面_小米电视盒子4值得买吗?双11选购必须要了解这几点
  3. 2022-2028年全球氢能存储行业收入年复合增长率CAGR为 19.9%
  4. 华为AP瘦模式转胖模式
  5. DeFi崛起:总锁仓量(TVL)不断飙升
  6. android status_bar_height动态调整,Android沉浸状态栏(StatusBar)兼容方案
  7. job是什么 oracle12c_Oracle 11g自带的系统Job介绍
  8. 【Unity3D插件】RuntimeTransformGizmos插件分享《Unity运行时控制模型插件》
  9. 2022年化工自动化控制仪表操作证考试题库及答案
  10. 电信运营商全渠道预售苹果6s手机