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

发布时间:2024年01月06日

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

#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

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

文章来源:https://blog.csdn.net/herocheney/article/details/135422086
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。