文章目录
前言
记录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版本选择,这里选择