ubuntu20.04安装cuda11.7和显卡驱动

1、禁用nouveau

sudo vi /etc/modprobe.d/nouveau.conf

在最下面加入blacklist nouveau

sudo update-initramfs -u

sudo reboot

输入命令,如果没有任何输出,证明禁用成功

lsmod | grep nouveau

2、安装cuda11.7

CUDA Toolkit Archive | NVIDIA Developer

CUDA Toolkit 11.7 Downloads | NVIDIA Developer

wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin

sudo mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600

wget https://developer.download.nvidia.com/compute/cuda/11.7.0/local_installers/cuda-repo-ubuntu2004-11-7-local_11.7.0-515.43.04-1_amd64.deb

sudo dpkg -i cuda-repo-ubuntu2004-11-7-local_11.7.0-515.43.04-1_amd64.deb

sudo cp /var/cuda-repo-ubuntu2004-11-7-local/cuda-*-keyring.gpg /usr/share/keyrings/

sudo apt-get update

sudo apt-get -y install cuda
export PATH=$PATH:/usr/local/cuda/bin  
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64  
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/cuda/lib64

source ~/.bashrc

sudo apt-get install libopencv-dev

1、QT

sudo apt install libxcb-xinerama0

注:安装系统时没有选择边安装边更新,此处会缺依赖库

sudo apt-get install build-essential

sudo apt-get install libgl1-mesa-dev

sudo apt-get install libglu1-mesa-dev

sudo apt-get install freeglut3-dev

sudo apt install gcc

sudo apt install g++

sudo apt install make

sudo apt install cmake cmake-gui

sudo apt install openssh-server

./qt-unified-linux-x64-online.run

sudo apt-get install libxcb-cursor0

export QTDIR=/home/visionnav/Qt/6.2.4/gcc_64

export PATH=QTDIR/bin:PATH

export LD_LIBRARY_PATH=QTDIR/lib:LD_LIBRARY_PATH

首先安装VTK的依赖:X11,OpenGL;cmake和cmake-gui在安装pcl依赖的时候安装过了的话可以跳过

X11

sudo apt-get install libx11-dev libxext-dev libxtst-dev libxrender-dev libxmu-dev libxmuu-dev

OpenGL

sudo apt-get install build-essential libgl1-mesa-dev libglu1-mesa-dev

cmake && cmake-gui

sudo apt-get install cmake cmake-gui

下载vtk9.1.0

Files · v9.1.0 · VTK / VTK · GitLab

配置cmake-gui config generate

make -j14

sudo make install

export VTK_DIR=/usr/local/include/vtk-9.1

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

cpp 复制代码
#include <vtkCubeSource.h>
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>

#include <vtkAutoInit.h>
VTK_MODULE_INIT(vtkRenderingOpenGL2) // 初始化OpenGL渲染模块
VTK_MODULE_INIT(vtkInteractionStyle) // 初始化交互式模块

int main()
{
    vtkSmartPointer<vtkCubeSource> cubeSource = vtkSmartPointer<vtkCubeSource>::New();

    vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
    mapper->SetInputConnection(cubeSource->GetOutputPort());

    vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
    actor->SetMapper(mapper);

    vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();
    renderer->AddActor(actor);

    vtkSmartPointer<vtkRenderWindow> renderWindow = vtkSmartPointer<vtkRenderWindow>::New();
    renderWindow->AddRenderer(renderer);

    vtkSmartPointer<vtkRenderWindowInteractor> interactor = vtkSmartPointer<vtkRenderWindowInteractor>::New();
    interactor->SetRenderWindow(renderWindow);

    renderWindow->Render();
    interactor->Start();

    return 0;
}

makefile

cpp 复制代码
CC = g++
CFLAGS = -I/usr/local/include/vtk-9.1/
LDFLAGS = -L/usr/local/lib
LIBS = -lvtkRenderingCore-9.1 -lvtkRenderingOpenGL2-9.1 -lvtkInteractionStyle-9.1 \
        -lvtkFiltersSources-9.1 -lvtkCommonExecutionModel-9.1 -lvtkCommonCore-9.1 \
        -lvtksys-9.1

SRC = vtk_test.cpp
OBJ = $(SRC:.cpp=.o)
EXECUTABLE = vtk_test

all: $(EXECUTABLE)

$(EXECUTABLE): $(OBJ)
        $(CC) $(LDFLAGS) $^ -o $@ $(LIBS)

.cpp.o:
        $(CC) $(CFLAGS) -c $< -o $@

clean:
        rm -f $(OBJ) $(EXECUTABLE)

PCL

sudo apt-get install libboost-all-dev

sudo apt-get install libeigen3-dev

sudo apt-get install libflann-dev

sudo apt-get install libqhull-dev

sudo apt-get install libusb-1.0-0-dev

sudo apt-get install libopenni-dev

Releases · PointCloudLibrary/pcl · GitHub

https://www.coin-or.org/download/source/metslib/metslib-0.5.3.tgz

sudo sh ./configure

sudo make

sudo make install

相关推荐
踏雪Vernon11 分钟前
[OpenHarmony5.0][环境][教程]OpenHarmony 5.0源码在WSL2 Ubuntu22.04 编译环境搭建教程
linux·docker·鸿蒙系统
vvw&16 分钟前
如何在 Ubuntu 22 04 上安装和配置 Ansible 自动化平台
linux·运维·服务器·ubuntu·自动化·github·ansible
AttackingLin20 分钟前
计网-命令行实现收发邮件
服务器·网络
元清加油1 小时前
【Git】:Git基本操作
运维·git
Knoka7051 小时前
本地推流,服务器拉流全流程
运维·服务器
davenian5 小时前
<OS 有关> ubuntu 24 不同版本介绍 安装 Vmware tools
linux·ubuntu·vmware
Simulink_6 小时前
ROS学习笔记15——Xacro
linux·笔记·学习·机器人·ros
北京迅为6 小时前
【北京迅为】iTOP-4412全能版使用手册- 第五章 Linux常用命令
linux·嵌入式硬件·4412开发板
南暮思鸢6 小时前
应急响应靶机——linux2
linux·网络安全·wireshark·write up·应急响应靶机系列·宝塔面板利用·webshell流量分析
sun0077007 小时前
ubuntu增加swap交换空间
linux·运维·服务器