CentOS tensorflow-gpu 搭建

1.安装基础依赖环境

Yum install gcc kernel-delve -y
 

注意事项,保证内核版本和源码版本一样,否则,安装报错误6:

 查看内核版本:

ls /boot | grep vmlinu
 

查看源码包版本

rpm -aq | grep kernel-devel
 

从上面的输出中可以看出内核版本号和内核源码版本。

2.源码安装


1 在英伟达官网下载相应驱动
搜索出相应的驱动后,不要直接点,而是右健,Save Link as...

否则,会出现下载半天没动静的情况。

存放的路径上最好不要有中文。

我存放的路径是 ~/Downloads/NVIDIA-Linux-x86_64-346.47.run

官网:NVIDIA 驱动程序下载

搜索后下载,根据自己的GUP选择,我的是2080Ti

2 屏蔽默认带有的nouveau

使用su命令切换到root用户下: su root

打开/lib/modprobe.d/dist-blacklist.conf

将nvidiafb注释掉。

#blacklist nvidiafb 
 

然后添加以下语句:

blacklist nouveau

options nouveau modeset=0


3 重建initramfs image步骤

mv /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.bak

dracut /boot/initramfs-$(uname -r).img $(uname -r) 


4 修改运行级别为文本模式(必须是文本模式下安装,否则报错)

systemctl set-default multi-user.target 


5 重新启动, 使用root用户登陆

reboot

6 查看nouveau是否已经禁用(必须禁用)

ls mod | grep nouveau
如果没有显示相关的内容,说明已禁用。

7 进入下载的驱动所在目录

chmod +x NVIDIA-Linux-x86_64-346.47.run

./NVIDIA-Linux-x86_64-346.47.run
安装过程中,选择accept

如果提示要修改xorg.conf,选择yes

测试:nvidia-smi                    如下图则成功

8 修改运行级别回图形模式

systemctl set-default graphical.target 


9 重新启动,OK

在Applications--Other可以看见NVIDIA X Server Settings菜单。 

问题:

错误1:
ERROR: The Nouveau kernel driver is currently in use by your system.  This driver is incompatible with the NVIDIA driver, and must be disabled before proceeding.  Please consult the NVIDIA driver README and your Linux distribution's documentation for details on how         to correctly disable the Nouveau kernel driver.
解释:如果没有执行屏蔽nouveau操作,报以上错误。

错误2:
unable to find the development too 'cc' in you path; please make sure that you have the package 'gcc
解决办法:

yum install gcc

错误4:
 ERROR: Unable to find the kernel source tree for the currently running kernel.  Please make sure you have installed the kernel source files for your

 kernel and that they are properly configured; on Red Hat Linux systems, for example, be sure you have the  'kernel-source' or 'kernel-devel' RPM installed.  If you know the correct kernel source files are installed, you may specify the kernel source path with the '--kernel-source-path' command line option.
解决办法:

yum install kernel-delve


错误5:
 ERROR: Unable to find the kernel source tree for the currently running kernel.  Please make sure you have installed the kernel source files for your kernel and that they are properly configured; on Red Hat Linux systems, for example, be sure you have the         'kernel-source' or 'kernel-devel' RPM installed.  If you know the correct kernel source files are installed, you may specify the kernel source path with the '--kernel-source-path' command line option.
 解决方法:

./NVIDIA-Linux-x86_64-390.67.run --kernel-source-path=/usr/src/kernels/3.10.0-862.3.2.el7.x86_64/ 


错误6:
ERROR: Unable to load the kernel module 'nvidia.ko'.  This happens most frequently when this kernel module was built against the wrong or improperly configured kernel sources, with a version of gcc that differs from the one used to build the target kernel, or if another driver, such as nouveau, is present and prevents the NVIDIA kernel module from obtaining ownership of the NVIDIA GPU(s), or no NVIDIA GPU installed in this system is supported by this NVIDIA Linux graphics driver release.

         Please see the log entries 'Kernel module load error' and 'Kernel messages' at the end of the file '/var/log/nvidia-installer.log' for more information.
解决办法:

可以通过以下方式查看内核版本和源码包版本:
ls /boot | grep vmlinuz
如果上面的命令输出中有多个内核,则按grub.conf中指定的文件为准。
rpm -aq | grep kernel-devel
kernel-devel-2.6.35.13-92.fc14.i686
从上面的输出中可以看出内核版本号和内核源码版本。为了解决这个错误,需要从FC官方网站上下载与内核版本对应的源码包进行安装。
         可以在以下网站下载并安装:
        http://rpmfind.net/linux/rpm2html/search.php?query=kernel-devel

备注:执行更新内核操作好需要重新执行屏蔽nouveau,及重建initramfs image步骤。

警告:
WARNING: nvidia-installer was forced to guess the X library path '/usr/lib64' and X module path '/usr/lib64/xorg/modules'; these paths were not queryable from the system.  If X fails to find the NVIDIA X driver module, please install the `pkg-config` utility and the

           X.Org SDK/development package for your distribution and reinstall the driver.
字符模式安装警告信息,可忽略。
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
TensorFlow是一个开源的人工智能框架,支持GPU加速计算。本文将提供在CentOS 7下安装TensorFlow-GPU的完整手册。 步骤1:安装GPU驱动程序 首先,确保您的机器已配置好NVIDIA显卡,并安装了相应版本的CUDA驱动程序。CUDA是用于在GPU上执行并行计算的一套工具。 步骤2:安装CUDA Toolkit 在CentOS 7上安装CUDA Toolkit,可以使用RPM包管理器。首先,下载适合您显卡型号的CUDA Toolkit安装包。然后,使用以下命令进行安装: ``` sudo rpm -i cuda-repo-<version>.rpm sudo yum clean expire-cache sudo yum install cuda ``` 步骤3:添加CUDA路径 安装完成后,需要将CUDA库路径添加到环境变量中。编辑`~/.bashrc`文件,并在文件末尾添加以下行: ``` export PATH=/usr/local/cuda/bin:$PATH export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH ``` 保存文件并执行以下命令使配置生效: ``` source ~/.bashrc ``` 步骤4:安装cuDNN cuDNN是用于加速深度神经网络计算的CUDA库。您需要注册NVIDIA开发者帐户才能下载cuDNN。一旦下载完成,使用以下命令解压文件: ``` tar -xzvf cudnn-<version>.tgz ``` 然后将文件复制到CUDA安装目录: ``` sudo cp cuda/include/cudnn.h /usr/local/cuda/include sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64 sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn* ``` 步骤5:安装Python和TensorFlowCentOS 7上,您可以使用Anaconda包管理器非常方便地安装Python和TensorFlow。首先,下载适合您操作系统版本的Anaconda安装包。然后,运行以下命令进行安装: ``` bash Anaconda3-<version>-Linux-x86_64.sh ``` 根据提示进行安装,并将Anaconda的bin目录添加到环境变量中。 步骤6:创建并激活虚拟环境 创建一个新的虚拟环境,以避免与现有的Python环境冲突: ``` conda create -n tensorflow python=3.7 conda activate tensorflow ``` 步骤7:安装TensorFlow-GPU 在虚拟环境中,使用conda命令安装TensorFlow-GPU: ``` conda install tensorflow-gpu ``` 安装完成后,您可以验证TensorFlow是否正确安装,可以使用以下代码进行测试: ``` import tensorflow as tf print(tf.__version__) ``` 如果能够成功输出TensorFlow版本号,则表示安装成功。 以上就是在CentOS 7下安装TensorFlow-GPU的完整手册。希望对您有帮助!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值