Fedora下使用negativo17.org提供的全套软件包安装配置NVIDIA 驱动/CUDA/tensorflow

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/OldBlackDog/article/details/80671580

前言

前段时间刚刚开始使用fedora作为主力系统,花在配置nvidia驱动和cuda上的时间精确讲来,也有两天两夜。忽然在外文论坛上提到了一个叫做'negativo17'的网站,搜搜看,惊为天人!

开始安装

通过以下命令来添加第三方仓库:

sudo dnf config-manager --addr-repo=https://negativo17.org/repos/fedora-nvidia.repo

然后开始安装:

sudo dnf install nvidia-settings kernel-devel dkms-nvidia vulkan.i686 nvidia-driver-libs.i686 cuda nvidia-driver-cuda cuda-devel cuda-cudart -y

后面的-y参数指所有的安装都默认同意,等dnf install结束后,整个NVIDIA驱动及CUDA就算是安装完成了,Belive it or not!从未如此简单!

测试NVIDIA DRIVER & CUDA

安装完成后,重启机器,测试我们的安装是否出错:

#使用nvidia-smi来输出显卡信息
nvidia-smi
#返回信息:
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 396.24                 Driver Version: 396.24                    |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  Quadro M500M        Off  | 00000000:06:00.0 Off |                  N/A |
| N/A   42C    P8    N/A /  N/A |    324MiB /  2004MiB |     11%      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0      1167      G   /usr/libexec/Xorg                             39MiB |
|    0      1481      G   /usr/bin/gnome-shell                          64MiB |
|    0      2174      G   /usr/libexec/Xorg                             97MiB |
|    0      2269      G   /usr/bin/gnome-shell                          66MiB |
|    0      3656      G   ...-token=769ABE7C8263C02869A3B5264FB7316C    54MiB |
+-----------------------------------------------------------------------------+

输出正确的显卡信息后,证明nvidia driver安装成功,我们再来测试CUDA:

#使用glxgears测试CUDA
glxgears
#返回如下:
Running synchronized to the vertical refresh.  The framerate should be
approximately the same as the monitor refresh rate.
47651 frames in 5.0 seconds = 9530.162 FPS
49648 frames in 5.0 seconds = 9929.438 FPS
49346 frames in 5.0 seconds = 9868.948 FPS

并在右上角有三个不同颜色的齿轮转动的话,说明CUDA也安装成功了!

安装cuDNN & Tensorflow 1.5

安装cuDNN:

sudo dnf install cuda-cudnn -y

安装Tensorflow:

#下载whl文件
curl -OL https://raw.githubusercontent.com/xd009642/tensorflow-gpu-fedora27-whl/master/tensorflow-1.5.0rc0-cp36-cp36m-linux_x86_64.whl
#通过pip3安装whl文件
pip3 install tensorflow-1.5.0rc0-cp36-cp36m-linux_x86_64.whl --user

至此,cuDNN及Tensorflow的安装也结束了。

最后的测试

#打开python解释器
python3
#测试tensorflow及cuDNN
import tensorflow as tf
test = tf.constant('Hello tensorflow !')
sess = tf.Session()
production = sess.run(test)
print(production)
#类似如下返回内容证明你就成功啦!
2018-06-12 09:26:09.028968: I tensorflow/core/platform/s3/aws_logging.cc:53] Initializing Curl library
2018-06-12 09:26:10.006883: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:898] 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-06-12 09:26:10.007304: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1206] Found device 0 with properties: 
name: Quadro M500M major: 5 minor: 0 memoryClockRate(GHz): 1.124
pciBusID: 0000:06:00.0
totalMemory: 1.96GiB freeMemory: 1.60GiB
2018-06-12 09:26:10.007322: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1300] Adding visible gpu device 0
2018-06-12 09:26:10.509256: I tensorflow/core/common_runtime/gpu/gpu_device.cc:987] Creating TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 1366 MB memory) -> physical GPU (device: 0, name: Quadro M500M, pci bus id: 0000:06:00.0, compute capability: 5.0)
b'Hello Tensorflow !'

安装整套Deep Learning环境的过程到此结束。

致谢:

# Nvidia driver,CUDA tools and libraries - negativo17.org

# Tensorflow 1.5 complied by yaroslavvb

阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页