ubuntu2204配置anacondacuda4090nvidia驱动

背景

某个机房的几台机器前段时间通过dnat暴露至公网后被入侵挖矿,为避免一些安全隐患将这几台机器执行重装系统操作;

这里主要记录配置nvidia驱动及cuda&anaconda。

步骤

大概分为几个步骤

  1. 禁用nouveau
  2. 配置grub显示菜单
  3. install nvidia-driver
  4. install cuda
  5. install anaconda
  6. 测试

执行

system info

root@xxx:~# cat /etc/os-release 
PRETTY_NAME="Ubuntu 22.04.3 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.3 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy
root@xxx:~# uname -a 
Linux exai-121 6.5.0-41-generic #41~22.04.2-Ubuntu SMP PREEMPT_DYNAMIC Mon Jun  3 11:32:55 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

禁用nouveau

echo -e "blacklist nouveau\noptions nouveau modeset=0" > /etc/modprobe.d/blacklist-nouveau.conf
update-initramfs -u

配置grub显示菜单

    sed -i 's/^GRUB_TIMEOUT=.*$/GRUB_TIMEOUT=10/' /etc/default/grub
    sed -i 's/^GRUB_TIMEOUT_STYLE=hidden/#&/' /etc/default/grub
    # 验证
    grep -E "GRUB_TIMEOUT" /etc/default/grub
    # 更新grub
    update-grub

install nvidia-driver

两种安装驱动的方法

  1. 添加ppa源的方式用apt安装
  2. 官网下载指定版本的离线安全包安装

方法一

使用ubuntu带的硬件扫描配合ppa源安装

# 扫描硬件
ubuntu-drivers devices

== /sys/devices/pci0000:00/0000:00:01.1/0000:01:00.0 ==
modalias : pci:v000010DEd00002684sv000010DEsd0000167Cbc03sc00i00
vendor   : NVIDIA Corporation
manual_install: True
driver   : nvidia-driver-535-server-open - distro non-free
driver   : nvidia-driver-535 - distro non-free recommended
driver   : nvidia-driver-545-open - distro non-free
driver   : nvidia-driver-535-server - distro non-free
driver   : nvidia-driver-545 - distro non-free
driver   : nvidia-driver-535-open - distro non-free
driver   : nvidia-driver-530 - third-party non-free
driver   : xserver-xorg-video-nouveau - distro free builtin
# apt安装需要的驱动版本即可 例如
apt install nvidia-driver-535 -y

方法二

编译器下载

apt update && apt install gcc make -y

官网下载535.183.01版本对应的离线安装run包
这里直接使用curl+proxy下载了

chmod +x NVIDIA-Linux-x86_64-535.183.01.run 
 ./NVIDIA-Linux-x86_64-535.183.01.run

过程中遇到的选项根据提示选择即可

root@xxx:~# nvidia-smi 
Thu Jul 14 09:xx:01 2024       
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 535.183.01             Driver Version: 535.183.01   CUDA Version: 12.2     |
|-----------------------------------------+----------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |         Memory-Usage | GPU-Util  Compute M. |
|                                         |                      |               MIG M. |
|=========================================+======================+======================|
|   0  NVIDIA GeForce RTX 4090        Off | 00000000:01:00.0 Off |                  Off |
| 32%   62C    P2             224W / 450W |  19736MiB / 24564MiB |     96%      Default |
|                                         |                      |                  N/A |
+-----------------------------------------+----------------------+----------------------+
|   1  NVIDIA GeForce RTX 4090        Off | 00000000:81:00.0 Off |                  Off |
| 31%   49C    P2             144W / 450W |  11430MiB / 24564MiB |     38%      Default |
|                                         |                      |                  N/A |
+-----------------------------------------+----------------------+----------------------+
|   2  NVIDIA GeForce RTX 4090        Off | 00000000:C1:00.0 Off |                  Off |
| 37%   63C    P2             140W / 450W |  11430MiB / 24564MiB |     39%      Default |
|                                         |                      |                  N/A |
+-----------------------------------------+----------------------+----------------------+
|   3  NVIDIA GeForce RTX 4090        Off | 00000000:C2:00.0 Off |                  Off |
| 32%   58C    P2             136W / 450W |  11430MiB / 24564MiB |     40%      Default |
|                                         |                      |                  N/A |
+-----------------------------------------+----------------------+----------------------+

其他常用命令
更详细的卸载请参考https://blog.csdn.net/qq_43652666/article/details/134705794

# 卸载nvidia驱动
nvidia-uninstall

如果系统没有nvidia-uninstall可以使用dpkg包管理器列出系统中的nvidia关键字的包进行卸载

dpkg -l |grep nvidia*
apt remove --purge '^nvidia-.*'

install cuda

https://developer.nvidia.com/cuda-toolkit-archive这里选择要下载的版本
下载对应的离线run包
在这里插入图片描述
执行安装的时候要取消自带安装的530版本驱动,因为本地已经有驱动了。
注意这里cuda后缀标识代表会安装530.30.02版本的驱动,而我们本地已经安装了535的驱动,cuda版本是向下兼容的。

root@xxx:~# chmod +x cuda_12.1.1_530.30.02_linux.run 
# 安装完成
root@exai-121:~# sh cuda_12.1.1_530.30.02_linux.run
===========
= Summary =
===========

Driver:   Not Selected
Toolkit:  Installed in /usr/local/cuda-12.1/

Please make sure that
 -   PATH includes /usr/local/cuda-12.1/bin
 -   LD_LIBRARY_PATH includes /usr/local/cuda-12.1/lib64, or, add /usr/local/cuda-12.1/lib64 to /etc/ld.so.conf and run ldconfig as root

To uninstall the CUDA Toolkit, run cuda-uninstaller in /usr/local/cuda-12.1/bin
***WARNING: Incomplete installation! This installation did not install the CUDA Driver. A driver of version at least 530.00 is required for CUDA 12.1 functionality to work.
To install the driver using this installer, run the following command, replacing <CudaInstaller> with the name of this run file:
    sudo <CudaInstaller>.run --silent --driver

Logfile is /var/log/cuda-installer.log

# 验证
root@xxx:~# /usr/local/cuda-12.1/bin/nvcc --version 
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2023 NVIDIA Corporation
Built on Mon_Apr__3_17:16:06_PDT_2023
Cuda compilation tools, release 12.1, V12.1.105
Build cuda_12.1.r12.1/compiler.32688072_0

ubuntu2204上不推荐使用530版本的驱动,安装会有一些依赖和GCC问题,尝试解决无果。推荐使用高版本驱动来向下兼容cuda版本。

问题:
make: *** [Makefile:82: modules] Error 2
-> Checking to see whether the nvidia kernel module was successfully built
executing: ‘cd ./kernel; /usr/bin/make -k -j32 NV_EXCLUDE_KERNEL_MODULES=“” SYSSRC=“/lib/modules/6.5.0-41-generic/build” SYSOUT=“/lib/modules/6.5.0-41-generic/build” NV_KERNEL_MODULES=“nvidia”’…
make[1]: Entering directory ‘/usr/src/linux-headers-6.5.0-41-generic’
warning: the compiler differs from the one used to build the kernel
The kernel was built by: x86_64-linux-gnu-gcc-12 (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0
You are using: cc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0

Warning: Compiler version check failed:

The major and minor number of the compiler used to
compile the kernel:

x86_64-linux-gnu-gcc-12 (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38

does not match the compiler used here:

cc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright © 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

It is recommended to set the CC environment variable
to the compiler that was used to compile the kernel.

To skip the test and silence this warning message, set
the IGNORE_CC_MISMATCH environment variable to “1”.
However, mixing compiler versions between the kernel
and kernel modules can result in subtle bugs that are
difficult to diagnose.
Failed CC version check.

The kernel was built by: x86_64-linux-gnu-gcc-12 (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0 You are using: cc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
make[3]: *** [scripts/Makefile.build:251: /tmp/selfgz2901/NVIDIA-Linux-x86_64-530.30.02/kernel/nvidia/i2c_nvswitch.o] Error 1
make[3]: Target ‘/tmp/selfgz2901/NVIDIA-Linux-x86_64-530.30.02/kernel/’ not remade because of errors.
make[2]: *** [/usr/src/linux-headers-6.5.0-41-generic/Makefile:2039: /tmp/selfgz2901/NVIDIA-Linux-x86_64-530.30.02/kernel] Error 2
make[2]: Target ‘modules’ not remade because of errors.
make[1]: *** [Makefile:234: __sub-make] Error 2
make[1]: Target ‘modules’ not remade because of errors.
make[1]: Leaving directory ‘/usr/src/linux-headers-6.5.0-41-generic’
make: *** [Makefile:82: modules] Error 2
ERROR: The nvidia kernel module was not created.
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.
/tmp/selfgz2901/NVIDIA-Linux-x86_64-530.30.02/kernel/common/inc/nv-mm.h:88:60: warning: passing argument 4 of ‘get_user_pages’ makes pointer from integer without a cast [-Wint-conversion]
/tmp/selfgz2901/NVIDIA-Linux-x86_64-530.30.02/kernel/nvidia/nv-mmap.c:673:23: error: assignment of read-only member ‘vm_flags’

尝试通过更换gcc版本解决:

update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 11
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 12
update-alternatives --config gcc
# 弹出来的选项中选择12版本

这是离线安装驱动方案下的问题,使用apt安装530版本未测试过,不确定包管理器是否会自动解决编译依赖问题

后续

使用sudo定制权限管理
https://blog.51cto.com/154773488/2449180
https://blog.csdn.net/Field_Yang/article/details/51547804

参考

https://www.cnblogs.com/tarsss/p/17433419.html
https://blog.csdn.net/jiexijihe945/article/details/131517630
cuda下载地址
https://developer.nvidia.com/cuda-toolkit-archive

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/843399.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

Linux云计算 |【第一阶段】ENGINEER-DAY3

主要内容&#xff1a; LVM逻辑卷管理、VDO、RAID磁盘阵列、进程管理 一、新建逻辑卷 1、什么是逻辑卷 逻辑卷&#xff08;Logical Volume&#xff09;是逻辑卷管理&#xff08;Logical Volume Management&#xff0c;LVM&#xff09;系统中的一个概念。LVM是一种用于磁盘管理…

SpringBoot集成MQTT实现交互服务通信

引言 本文是springboot集成mqtt的一个实战案例。 gitee代码库地址&#xff1a;源码地址 一、什么是MQTT MQTT&#xff08;Message Queuing Telemetry Transport&#xff0c;消息队列遥测传输协议&#xff09;&#xff0c;是一种基于发布/订阅&#xff08;publish/subscribe&…

[Armbian] 部署Docker版Home Assistent,安装HACS并连接米家设备

title: [Armbian] 部署Docker版Home Assistent&#xff0c;安装HACS并连接米家设备 date: 2024-07-21T10:51:23Z lastmod: 2024-07-21T11:40:39Z [Armbian] 部署Docker版Home Assistent&#xff0c;安装HACS并连接米家设备 官网&#xff1a;Home Assistant (home-assistant.i…

sql常见50道查询练习题

sql常见50道查询练习题 1. 表创建1.1 表创建1.2 数据插入 2. 简单查询例题(3题&#xff09;2.1 查询"李"姓老师的数量2.2 查询男生、女生人数2.3 查询名字中含有"风"字的学生信息 3. 日期相关例题(6题&#xff09;3.1 查询各学生的年龄3.2 查询本周过生日的…

Yolo-World网络模型结构及原理分析(一)——YOLO检测器

文章目录 概要一、整体架构分析二、详细结构分析YOLO检测器1. Backbone2. Head3.各模块的过程和作用Conv卷积模块C2F模块BottleNeck模块SPPF模块Upsampling模块Concat模块 概要 尽管YOLO&#xff08;You Only Look Once&#xff09;系列的对象检测器在效率和实用性方面表现出色…

【GraphRAG】微软 graphrag 效果实测

GraphRAG 本文将基于以下来源&#xff0c;对Microsoft GraphRAG分析优缺点、以及示例实测分析。 1. Source 代码仓库&#xff1a; Welcome to GraphRAGhttps://microsoft.github.io/graphrag/ 微软文章1&#xff08;2024.2.13&#xff09;&#xff1a;GraphRAG: Unlocking…

通过albumentation对目标检测进行数据增强(简单直接)

albumentation官方文档看不懂&#xff1f;xml文件不知道如何操作&#xff1f;下面只需要修改部分代码即可上手使用 要使用这个方法之前需要按照albumentation这个库还有一些辅助库,自己看着来安装就行 pip install albumentation pip install opencv-python pip install json…

阿尔泰科技利用485模块搭建自动灌溉系统实现远程控制

自动灌溉系统又叫土壤墒情监控系统&#xff0c;土壤墒情监控系统主要实现固定站无人值守情况下的土壤墒情数据的自动采集和无线传输&#xff0c;数据在监控中心自动接收入库&#xff1b;可以实现24小时连续在线监控并将监控数据通过有线、无线等传输方式实时传输到监控中心生成…

破解反爬虫策略 /_guard/auto.js(二)实战

这次我们用上篇文章讲到的方法来真正破解一下反爬虫策略&#xff0c;这两个案例是两个不同的网站&#xff0c;一个用的是 /_guard/auto.js&#xff0c;另一个用的是/_guard/delay_jump.js。经过解析发现这两个网站用的反爬虫策略基本是一模一样&#xff0c;只不过在js混淆和生成…

FOG Project 文件名命令注入漏洞复现(CVE-2024-39914)

0x01 产品简介 FOG是一个开源的计算机镜像解决方案,旨在帮助管理员轻松地部署、维护和克隆大量计算机。FOG Project 提供了一套功能强大的工具,使用户能够快速部署操作系统、软件和配置设置到多台计算机上,从而节省时间和精力。该项目支持基于网络的 PXE 启动、镜像创建和还…

Python | Leetcode Python题解之第240题搜索二维矩阵II

题目&#xff1a; 题解&#xff1a; class Solution:def searchMatrix(self, matrix: List[List[int]], target: int) -> bool:m, n len(matrix), len(matrix[0])x, y 0, n - 1while x < m and y > 0:if matrix[x][y] target:return Trueif matrix[x][y] > tar…

使用崖山YMP 迁移 Oracle/MySQL 至YashanDB 23.2 验证测试

前言 首届YashanDB「迁移体验官」开放后&#xff0c;陆续收到「体验官」们的投稿&#xff0c;小崖在此把优秀的投稿文章分享给大家~今天分享的用户文章是《使用崖山YMP 迁移 Oracle/MySQL 至YashanDB 23.2 验证测试》&#xff08;作者&#xff1a;尚雷&#xff09;&#xff0c…

数据结构(队列及其实现)

概念与结构 概念&#xff1a;只允许在⼀端进⾏插⼊数据操作&#xff0c;在另⼀端进⾏删除数据操作的特殊线性表&#xff0c; 队列具有先进先出FIFO(First In First Out)原则。 ⼊队列&#xff1a;进⾏插⼊操作的⼀端称为队尾 出队列&#xff1a;进⾏删除操作的⼀端称为队头…

MyBatis 持久层框架-上

一、Mybatis 简介 1. 简介 MyBatis 是一款优秀的持久层框架&#xff0c;它支持自定义SQL、存储过程以及高级映射。MyBatis 免除了几乎所有的 JDBC 代码以及设置参数和获取结果集的工作。MyBatis 可以通过简单的 XML 或注解来配置和映射原始类型、接口和Java POJO 为数据库中的记…

使用SpringAOP解决日志记录问题+获取MyBatis执行的SQL语句(企业中常用的日志审计功能)

前言 需求是这样的&#xff1a;每个接口都有不同的数据库操作。想要将这些请求和数据库操作放到日志当中&#xff0c;方便管理员查看有哪些操作被执行了。这里排除查询操作&#xff0c;只在日志中记录 update、insert、delete 这三个操作。期望的日志表中应该有每次执行的 sql …

基于电鸿(电力鸿蒙)的边缘计算网关,支持定制

1 产品信息 边缘计算网关基于平头哥 TH1520 芯片&#xff0c;支持 OpenHarmony 小型系统&#xff0c;是 连接物联网设备和云平台的重要枢纽&#xff0c;可应用于城市基础设施&#xff0c;智能工厂&#xff0c;智能建筑&#xff0c;营业网点&#xff0c;运营 服务中心相关场…

RK3568笔记四十一:DHT11驱动开发测试

若该文为原创文章&#xff0c;转载请注明原文出处。 记录开发单总线&#xff0c;读取DHT11温湿度 一、DHT11介绍 DHT11是串行接口&#xff08;单线双向&#xff09;DATA 用于微处理器与 DHT11之间的通讯和同步&#xff0c;采用单总线数据格式&#xff0c;一次通讯时间4ms左右…

好用的AI搜索引擎

1. 360AI 搜索 访问 360AI 搜索: https://www.huntagi.com/sites/1706642948656.html 360AI 搜索介绍&#xff1a; 360AI 搜索&#xff0c;新一代智能答案引擎&#xff0c;值得信赖的智能搜索伙伴&#xff0c;为复杂搜索提供专业支持&#xff0c;解锁更相关、更全面的答案。AI…

视频汇聚,GB28181,rtsp,rtmp,sip,webrtc,视频点播等多元异构视频融合,视频通话,视频会议交互方案

现在视频汇聚&#xff0c;视频融合和视频互动&#xff0c;是视频技术的应用方向&#xff0c;目前客户一般有很多视频的业务系统&#xff0c;如已有GB28181的监控&#xff08;GB现在是国内主流&#xff0c;大量开源接入和商用方案&#xff09;&#xff0c;rtsp设备&#xff0c;音…

建筑集团工程地产类公司网站源码系统 带完整的安装代码包以及搭建部署教程

系统概述 在数字化浪潮的推动下&#xff0c;建筑行业正经历着前所未有的变革。为了提升企业形象&#xff0c;优化客户体验&#xff0c;加强项目管理&#xff0c;建筑集团工程地产类公司急需一套高效、易用的网站源码系统。小编给大家分享一款专为建筑行业量身定制的网站源码系…