驱动安装
添加ppa后查看推荐的驱动
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
ubuntu-drivers devices
显示nvidia-driver-535为推荐版本,安装
sudo apt install nvidia-driver-535
安装完成后重启电脑
nvidia-smi
显示显卡与驱动信息,说明驱动安装成功。
安装cuda
安装编译相关工具
sudo apt install build-essential
安装cuda包
sudo apt install nvidia-cuda-toolkit nvidia-cuda-toolkit-gcc
测试
以cu结尾保存以下程序
#include <stdio.h>
__global__ void sayHello() {
printf("Hello world from the GPU!\n");
}
int main() {
printf("Hello world from the CPU!\n");
sayHello<<<1,1>>>();
cudaDeviceSynchronize();
return 0;
}
编译并执行
nvcc hello.cu -o hello
./hello
输出Hello world from the GPU即成功
标签:ppa,sudo,apt,cuda,nvidia,安装,ubuntu,搭建 From: https://www.cnblogs.com/chilkings/p/17598743.html