老山君 發表於 2021-1-20 13:58:00

centos 安装cuda

<h1 id="零-修订记录">零 修订记录</h1>
<table>
<thead>
<tr>
<th>序号</th>
<th>修订内容</th>
<th>修订时间</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>新增</td>
<td>2021/1/20</td>
</tr>
</tbody>
</table>
<h1 id="一-摘要">一 摘要</h1>
<p>本文主要介绍centos 8.1 安装cuda</p>
<h1 id="二-环境信息">二 环境信息</h1>
<h2 id="一-操作系统">(一) 操作系统</h2>
<pre><code># cat /etc/centos-release
CentOS Linux release 8.1.1911 (Core)
#

</code></pre>
<h2 id="二-cuda-版本">(二) cuda 版本</h2>
<p>我这里用的是<br>
cuda_10.2.89_440.33.01_linux.run</p>
<h1 id="三-实施">三 实施</h1>
<h2 id="一准备工作">(一)准备工作</h2>
<h3 id="311-检查机器是否装有支持cuda的gpu">3.1.1 检查机器是否装有支持cuda的gpu</h3>
<pre><code># lspci | grep -i nvidia
af:00.0 3D controller: NVIDIA Corporation TU104GL (rev a1)
#

</code></pre>
<h3 id="312-下载">3.1.2 下载</h3>
<p>此处先略</p>
<h2 id="二-runfile-安装">(二) runfile 安装</h2>
<h3 id="321-安装基础依赖">3.2.1 安装基础依赖</h3>
<pre><code># yum install gcc

</code></pre>
<p>这个可以不要</p>
<pre><code># yum install libglu1-mesa libxi-dev libxmu-dev libglu1-mesa-dev freeglut3-dev

</code></pre>
<h3 id="322-关闭-the-nouveau-drivers">3.2.2 关闭 the Nouveau drivers</h3>
<h4 id="3221-检查nouveau-驱动是否启动">3.2.2.1 检查nouveau 驱动是否启动</h4>
<pre><code>#lsmod | grep nouveau
nouveau            22159361
mxm_wmi                163841 nouveau
video                  450561 nouveau
wmi                  327682 mxm_wmi,nouveau
i2c_algo_bit         163842 ast,nouveau
drm_kms_helper      2170882 ast,nouveau
ttm                   1105922 ast,nouveau
drm                   5242887 drm_kms_helper,ast,ttm,nouveau
#

</code></pre>
<p>有输出表示启动了。</p>
<h4 id="3222-关闭nouveau-驱动">3.2.2.2 关闭nouveau 驱动</h4>
<h5 id="32221-新增黑名单">3.2.2.2.1 新增黑名单</h5>
<p>To disable the Nouveau drivers, creating a file at "/usr/lib/modprobe.d/blacklist-nouveau.conf" with following content:</p>
<pre><code>blacklist nouveau

options nouveau modeset=0
</code></pre>
<pre><code># ll /usr/lib/modprobe.d/blacklist-nouveau.conf
ls: cannot access '/usr/lib/modprobe.d/blacklist-nouveau.conf': No such file or directory
# vim /usr/lib/modprobe.d/blacklist-nouveau.conf
#

# cat /usr/lib/modprobe.d/blacklist-nouveau.conf
blacklist nouveau
options nouveau modeset=0
#

</code></pre>
<h5 id="32222-重新生成-kernel-inittramfs">3.2.2.2.2 重新生成 kernel inittramfs</h5>
<p>先备份</p>
<pre><code># uname -r
4.18.0-147.el8.x86_64
# cp /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.bak.orig
# ll
total 167724
-rw-------. 1 root root3838259 Dec52019 System.map-4.18.0-147.el8.x86_64
-rw-r--r--. 1 root root   184613 Dec52019 config-4.18.0-147.el8.x86_64
drwxr-xr-x. 3 root root   4096 Jan 19 11:44 efi
drwx------. 4 root root   4096 Jan 19 15:02 grub2
-rw-------. 1 root root 71694380 Jan 19 11:49 initramfs-0-rescue-c7dcb861dc20453f8e275d6036842581.img
-rw-------. 1 root root 30310567 Jan 19 11:50 initramfs-4.18.0-147.el8.x86_64.img
-rw-------1 root root 30310567 Jan 20 13:50 initramfs-4.18.0-147.el8.x86_64.img.bak.orig
-rw-------. 1 root root 19141009 Jan 19 11:57 initramfs-4.18.0-147.el8.x86_64kdump.img
drwxr-xr-x. 3 root root   4096 Jan 19 11:47 loader
drwx------. 2 root root    16384 Jan 19 11:28 lost+found
-rwxr-xr-x. 1 root root8106744 Jan 19 11:48 vmlinuz-0-rescue-c7dcb861dc20453f8e275d6036842581
-rwxr-xr-x. 1 root root8106744 Dec52019 vmlinuz-4.18.0-147.el8.x86_64
#

</code></pre>
<p>再重新生成</p>
<pre><code># dracut/boot/initramfs-$(uname -r).img --force
# ll
total 166988
-rw-------. 1 root root3838259 Dec52019 System.map-4.18.0-147.el8.x86_64
-rw-r--r--. 1 root root   184613 Dec52019 config-4.18.0-147.el8.x86_64
drwxr-xr-x. 3 root root   4096 Jan 19 11:44 efi
drwx------. 4 root root   4096 Jan 19 15:02 grub2
-rw-------. 1 root root 71694380 Jan 19 11:49 initramfs-0-rescue-c7dcb861dc20453f8e275d6036842581.img
-rw-------. 1 root root 29560525 Jan 20 13:53 initramfs-4.18.0-147.el8.x86_64.img
-rw-------1 root root 30310567 Jan 20 13:50 initramfs-4.18.0-147.el8.x86_64.img.bak.orig
-rw-------. 1 root root 19141009 Jan 19 11:57 initramfs-4.18.0-147.el8.x86_64kdump.img
drwxr-xr-x. 3 root root   4096 Jan 19 11:47 loader
drwx------. 2 root root    16384 Jan 19 11:28 lost+found
-rwxr-xr-x. 1 root root8106744 Jan 19 11:48 vmlinuz-0-rescue-c7dcb861dc20453f8e275d6036842581
-rwxr-xr-x. 1 root root8106744 Dec52019 vmlinuz-4.18.0-147.el8.x86_64
#

</code></pre>
<h4 id="3223-运行级别修改为文本模式">3.2.2.3 运行级别修改为文本模式</h4>
<pre><code># systemctl set-default multi-user.target
Removed /etc/systemd/system/default.target.
Created symlink /etc/systemd/system/default.target → /usr/lib/systemd/system/multi-user.target.
#

</code></pre>
<p>修改完重启机器</p>
<h3 id="323-安装cuda_10289_4403301_linuxrun">3.2.3 安装cuda_10.2.89_440.33.01_linux.run</h3>
<h4 id="3231-step-by-step">3.2.3.1 step by step</h4>
<pre><code># sh cuda_10.2.89_440.33.01_linux.run

</code></pre>
<p>该命令执行后需要等一段时间<br>
输入accept<br>
<img src="https://img2020.cnblogs.com/blog/2194335/202101/2194335-20210120150132497-1855212769.png" alt="" loading="lazy"></p>
<p>选择install<br>
<img src="https://img2020.cnblogs.com/blog/2194335/202101/2194335-20210120150153197-641840356.png" alt="" loading="lazy"></p>
<p>装失败了<br>
报错日志</p>
<pre><code># cat nvidia-installer.log
nvidia-installer log file '/var/log/nvidia-installer.log'
creation time: Wed Jan 20 14:59:43 2021
installer version: 440.33.01

PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

nvidia-installer command line:
    ./nvidia-installer
    --ui=none
    --no-questions
    --accept-license
    --disable-nouveau
    --no-cc-version-check
    --install-libglvnd

Using built-in stream user interface
-&gt; Detected 48 CPUs online; setting concurrency level to 32.
-&gt; Installing NVIDIA driver version 440.33.01.
WARNING: One or more modprobe configuration files to disable Nouveau are already present at: /usr/lib/modprobe.d/nvidia-installer-disable-nouveau.conf, /etc/modprobe.d/nvidia-installer-disable-nouveau.conf.Please be sure you have rebooted your system since these files were written.If you have rebooted, then Nouveau may be enabled for other reasons, such as being included in the system initial ramdisk or in your X configuration file.Please consult the NVIDIA driver README and your Linux distribution's documentation for details on how to correctly disable the Nouveau kernel driver.
-&gt; For some distributions, Nouveau can be disabled by adding a file in the modprobe configuration directory.Would you like nvidia-installer to attempt to create this modprobe file for you? (Answer: Yes)
-&gt; One or more modprobe configuration files to disable Nouveau have been written.For some distributions, this may be sufficient to disable Nouveau; other distributions may require modification of the initial ramdisk.Please reboot your system and attempt NVIDIA driver installation again.Note if you later wish to reenable Nouveau, you will need to delete these files: /usr/lib/modprobe.d/nvidia-installer-disable-nouveau.conf, /etc/modprobe.d/nvidia-installer-disable-nouveau.conf
ERROR: Unable to find the development tool `make` in your path; please make sure that you have the package 'make' installed.If make is installed on your system, then please check that `make` is in your PATH.
ERROR: Installation has failed.Please see the file '/var/log/nvidia-installer.log' for details.You may find suggestions on fixing installation problems in the README available on the Linux driver download page at www.nvidia.com.
#

</code></pre><br><br>
来源:https://www.cnblogs.com/weiwei2021/p/14302530.html
頁: [1]
查看完整版本: centos 安装cuda