Ubuntu 18.04搭建TensorFlow模型训练环境的笔记


前言

记录Ubuntu 18.04搭建模型训练环境的笔记


一、安装Ubuntu系统

此次搭建选择Ubuntu 18.04系统,安装教程百度。安装完成之后设置固定IP与切换国内源。
在这里插入图片描述
切换国内源之后更新一下apt

sudo apt update
sudo apt upgrade

二、安装显卡驱动

1.删除原有驱动

sudo apt remove --purge nvidia*
sudo apt autoremove nvidia*

2.禁用nouveau驱动(开源显卡驱动)

编辑/etc/modprobe.d/blacklist-nouveau.conf文件

vim /etc/modprobe.d/blacklist-nouveau.conf

添加以下内容:

blacklist nouveau
options nouveau modeset=0

保存后执行以下命令更新改动:

sudo update-initramfs -u

重启系统

sudo reboot

重启之后输入:

lsmod | grep nouveau

如果没有输出信息,则禁用nouveau成功

3.关闭桌面系统

sudo service lightdm stop

4.安装显卡驱动

原文链接:https://blog.csdn.net/JineD/article/details/131201121
登录NVIDIA官网,可以选择适合自己电脑的驱动,下载下来。此次下载的驱动文件:NVIDIA-Linux-x86_64-535.146.02.run

给驱动文件添加可执行权限:

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

安装gcc、make:

sudo apt install gcc make

开始安装显卡驱动

sudo NVIDIA-Linux-x86_64-535.146.02.run

每次安装都会出现如下提示,实际上pre-install固定会失败的,目的就是为了让你知道你自己在干嘛,选择Continue installation

The distribution-provided pre-install script failed! Are you sure you want to continue?

如下提示是否需要32位兼容,不需要 no即可

Unable to find a suitable destination to install 32-bit compatibility libraries. 
Your system may not be set up for 32-bit compatibility. 32-bit compatibility files will not be installed; 
if you wish to install them, re-run the installation and set a valid directory with the --compat32-libdir option.

DKMS注册内核模块,直接no不需要

Would you like to register the kernel module sources with DKMS? 
This will allow DKMS to automatically build a new module, 
if you install a different kernel later

然后会有如下过程提示,是否运行Nvidia-xconfig来配置X configuration文件,选择yes

Would you like to run the nvidia-xconfig utility to automatically update your X configuration file so that the
NVIDIA X driver will be used when you restart X?  Any pre-existing X configuration file will be backed up.

Tips: 如果提示这个Error,说明Xserver还没关,重新执行上面的关闭Xserver (即关闭桌面系统)

ERROR: You appear to be running an X server; please exit X before installing.  
For further details, please see the section INSTALLING THE NVIDIA DRIVER in the README available on the Linux driver download page at www.nvidia.com.

验证安装,执行nvidia-smi命令能看到显卡相关信息即可,其中的CUDA Version: 12.2为最高能支持到的cuda版本,并非当前系统安装的cuda版本
在这里插入图片描述

三、安装CUDA

前往官网下载CUDA:https://developer.nvidia.com/cuda-toolkit-archive/
在这里插入图片描述
按显卡驱动的最大支持CUDA版本选择,这里选择

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值