ubuntu cuda 安装成功 ubuntu安装run文件
Ubuntu24.04配置cuda、cudnn
首先,对于Ubuntu 24.04的CUDA和CUDNN配置,关键步骤如下:
1.确保显卡驱动已安装:检查电脑当前的显卡驱动,确认是否为支持CUDA的版本。如果需要更新,可以从显卡制造商的官方网站下载安装程序,然后按照指示进行安装。安装完成后,通过命令行验证驱动是否成功加载。
2.安装CUDA 12.2:
访问CUDA 12.2的官方下载链接进行下载。
在终端中,打开bash配置文件:vi~/.bashrc,为新安装的CUDA设置环境变量。
3.安装CUDNN:同样从官方或可信源获取CUDNN对应CUDA版本的下载文件。
安装CUDNN后,验证其是否成功安装,可以通过CUDA管理工具或运行特定的CUDNN测试程序来确认。
ubuntu14.04怎么测试cuda是否安装成功
首先,我装的系统是Ubuntu 14.04.1。
1.预检查
按照参考链接1中所示,检查系统。
执行命令:
:~$ lspci| grep-i nvidia
03:00.0 3D controller: NVIDIA Corporation GK110GL [Tesla K20c](rev a1)
04:00.0 VGA compatible controller: NVIDIA Corporation GK106GL [Quadro K4000](rev a1)
04:00.1 Audio device: NVIDIA Corporation GK106 HDMI Audio Controller(rev a1)
发现有K20和K4000两块GPU,还有一块Audio的应该是声卡。
然后,执行命令检查系统版本:
~$ uname-m&& cat/etc/*release
x86_64
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04.1 LTS"
NAME="Ubuntu"
VERSION="14.04.1 LTS, Trusty Tahr"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 14.04.1 LTS"
VERSION_ID="14.04"
HOME_URL=""
SUPPORT_URL=""
BUG_REPORT_URL=""
可以看到,机器是ubuntu14.04的版本。
然后,使用gcc--version检查gcc版本是否符合链接1中的要求:
~$ gcc--version
gcc(Ubuntu 4.8.2-19ubuntu1) 4.8.2
Copyright(C) 2013 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.
检查完毕,就去nvidia的官网(参考链接3)上下载驱动,为下载的是ubuntu14.04的deb包。
2.安装
Deb包安装较为简单,但是安装过程中提示不稳定,不过用着也没啥出错的地方。
先按照参考链接2安装必要的库。
sudo apt-get install freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libgl1-mesa-glx libglu1-mesa libglu1-mesa-dev
还是按照官网上的流程来。
$ sudo dpkg-i cuda-repo-<distro>_<version>_<architecture>.deb
$ sudo apt-get update
$ sudo apt-get install cuda
可能需要下载较长时间,但是没关系,放在那等着就是。
没啥问题就算安装好了。
安装过程中提示:
*** Please reboot your computer and verify that the nvidia graphics driver is loaded.***
*** If the driver fails to load, please use the NVIDIA graphics driver.run installer***
*** to get into a stable state.
我没管,提示使用.run安装比较稳定,但我现在用着没问题。
3.配置环境
我的系统是64位的,因此配置环境时在.bashrc中加入
$ export PATH=/usr/local/cuda-6.5/bin:$PATH
$ export LD_LIBRARY_PATH=/usr/local/cuda-6.5/lib64:$LD_LIBRARY_PATH
配置完环境后,执行命令
~$ source.bashrc
使其立刻生效。
4.安装sample
配置好环境后,可以执行如下命令:
$ cuda-install-samples-6.5.sh<dir>
这样,就将cuda的sample拷贝到dir文件夹下了。该命令只是一个拷贝操作。
然后进入该文件夹,执行make命令进行编译,编译时间较长,需要等待。
5.验证安装是否成功
5.1.驱动验证
首先,验证nvidia的驱动是否安装成功。
~$ cat/proc/driver/nvidia/version
NVRM version: NVIDIA UNIX x86_64 Kernel Module 340.29 Thu Jul 31 20:23:19 PDT 2014
GCC version: gcc version 4.8.2(Ubuntu 4.8.2-19ubuntu1)
5.2. Toolkit验证
验证cuda toolkit是否成功。
~$ nvcc-V
nvcc: NVIDIA(R) Cuda compiler driver
Copyright(c) 2005-2014 NVIDIA Corporation
Built on Thu_Jul_17_21:41:27_CDT_2014
Cuda compilation tools, release 6.5, V6.5.12
5.3.设备识别
使用cuda sample已经编译好的deviceQuery来验证。deviceQuery在<cuda_sample_install_path>/bin/x_86_64/linux/release目录下。我的结果如下,检测出了两块GPU来。
~/install/NVIDIA_CUDA-6.5_Samples/bin/x86_64/linux/release$./deviceQuery
./deviceQuery Starting...
CUDA Device Query(Runtime API) version(CUDART static linking)
Detected 2 CUDA Capable device(s)
Device 0:"Tesla K20c"
CUDA Driver Version/ Runtime Version 6.5/ 6.5
CUDA Capability Major/Minor version number: 3.5
Total amount of global memory: 4800 MBytes(5032706048 bytes)
(13) Multiprocessors,(192) CUDA Cores/MP: 2496 CUDA Cores
GPU Clock rate: 706 MHz(0.71 GHz)
Memory Clock rate: 2600 Mhz
Memory Bus Width: 320-bit
L2 Cache Size: 1310720 bytes
Maximum Texture Dimension Size(x,y,z) 1D=(65536), 2D=(65536, 65536), 3D=(4096, 4096, 4096)
Maximum Layered 1D Texture Size,(num) layers 1D=(16384), 2048 layers
Maximum Layered 2D Texture Size,(num) layers 2D=(16384, 16384), 2048 layers
Total amount of constant memory: 65536 bytes
Total amount of shared memory per block: 49152 bytes
Total number of registers available per block: 65536
Warp size: 32
Maximum number of threads per multiprocessor: 2048
Maximum number of threads per block: 1024
Max dimension size of a thread block(x,y,z):(1024, 1024, 64)
Max dimension size of a grid size(x,y,z):(2147483647, 65535, 65535)
Maximum memory pitch: 2147483647 bytes
Texture alignment: 512 bytes
Concurrent copy and kernel execution: Yes with 2 copy engine(s)
Run time limit on kernels: No
Integrated GPU sharing Host Memory: No
Support host page-locked memory mapping: Yes
Alignment requirement for Surfaces: Yes
Device has ECC support: Enabled
Device supports Unified Addressing(UVA): Yes
Device PCI Bus ID/ PCI location ID: 3/ 0
Compute Mode:
< Default(multiple host threads can use::cudaSetDevice() with device simultaneously)>
Device 1:"Quadro K4000"
CUDA Driver Version/ Runtime Version 6.5/ 6.5
CUDA Capability Major/Minor version number: 3.0
Total amount of global memory: 3071 MBytes(3220504576 bytes)
( 4) Multiprocessors,(192) CUDA Cores/MP: 768 CUDA Cores
GPU Clock rate: 811 MHz(0.81 GHz)
Memory Clock rate: 2808 Mhz
Memory Bus Width: 192-bit
L2 Cache Size: 393216 bytes
Maximum Texture Dimension Size(x,y,z) 1D=(65536), 2D=(65536, 65536), 3D=(4096, 4096, 4096)
Maximum Layered 1D Texture Size,(num) layers 1D=(16384), 2048 layers
Maximum Layered 2D Texture Size,(num) layers 2D=(16384, 16384), 2048 layers
Total amount of constant memory: 65536 bytes
Total amount of shared memory per block: 49152 bytes
Total number of registers available per block: 65536
Warp size: 32
Maximum number of threads per multiprocessor: 2048
Maximum number of threads per block: 1024
Max dimension size of a thread block(x,y,z):(1024, 1024, 64)
Max dimension size of a grid size(x,y,z):(2147483647, 65535, 65535)
Maximum memory pitch: 2147483647 bytes
Texture alignment: 512 bytes
Concurrent copy and kernel execution: Yes with 1 copy engine(s)
Run time limit on kernels: Yes
Integrated GPU sharing Host Memory: No
Support host page-locked memory mapping: Yes
Alignment requirement for Surfaces: Yes
Device has ECC support: Disabled
Device supports Unified Addressing(UVA): Yes
Device PCI Bus ID/ PCI location ID: 4/ 0
Compute Mode:
< Default(multiple host threads can use::cudaSetDevice() with device simultaneously)>
> Peer access from Tesla K20c(GPU0)-> Quadro K4000(GPU1): No
> Peer access from Quadro K4000(GPU1)-> Tesla K20c(GPU0): No
deviceQuery, CUDA Driver= CUDART, CUDA Driver Version= 6.5, CUDA Runtime Version= 6.5, NumDevs= 2, Device0= Tesla K20c, Device1= Quadro K4000
Result= PASS
这样,cuda就安装成功了。
Ubuntu16.04无法安装CUDA吗
Ubuntu 16.04安装 CUDA7.5
作者:autocyz
在介绍Ubuntu 16.04安装 CUDA7.5开始前,先辨析几个概念GPU、NVIDIA、NVIDIA驱动、CUDA、cudnn等,这些概念对于一个新手来说肯定是很晕的,正如我当初一样,所以我这里就稍微介绍一下这几个概念:
GPU:Graphics Processing Units,也就是我们常说的显卡。现在的笔记本或者台式机都会有显卡,但是能够让我们用来做并行计算的真正的GPU就只有NVIDIA出产的GPU了。
NVIDIA:GPU生产厂商,在运算GPU处于垄断地位。
NVIDIA驱动:就是NVIDIA生产的GPU想在电脑上正常使用所需的驱动。
CUDA:Compute Unified Device Architecture,是显卡厂商NVIDIA推出的运算平台。 CUDA是一种由NVIDIA推出的通用并-行计算架构,该架构使GPU能够解决复杂的计算问题。我们想使用GPU进行深度学习运算的时候,必须要用到这个运算平台。
cudnn:CuDNN是NVIDIA专门针对Deep Learning框架设计的一套GPU计算加速方案,目前支持的DL库包括Caffe,ConvNet, Torch7等.
Ubuntu 16.04安装cuda7.5
部分参照:
在安装之前,先说一下本人工作站的设备配置(主要是GPU的):
设备上一共有三块GPU,一快是专门用来做显示的NVS310
两块用来做运算的GeForce GTX TITIAN X
第一步:选择最新的nvidia驱动(很重要!!!)
先打开计算机中的“软件和更新”,查看“附加驱动”,选择nvidia的驱动为最新的驱动。更新完之后最好重启一下。
我曾经遇到一些错误,就是因为我的NVIDIA驱动太老了,而cuda7.5则依赖于比较新的驱动。
第二步:下载cuda
去官网下载,选择Linux——ubuntu——15.04(我安装的时候还只支持到15.04,没有支持16.04版本的)——runfile(local)
第三步:安装PPA软件管理包工具
什么是 PPA?
PPA,表示 Personal Package Archives,也就是个人软件包集。
有很多软件因为种种原因,不能进入官方的 Ubuntu软件仓库。为了方便 Ubuntu用户使用,launchpad.NET提供了 ppa,允许用户建立自己的软件仓库,自由的上传软件。PPA也被用来对一些打算进入 Ubuntu官方仓库的软件,或者某些软件的新版本进行测试。PPA上的软件极其丰富,如果 Ubuntu官方仓库中缺少您需要的某款软件,可以去 PPA上找找看。
我们安装的cuda可能在Ubuntu仓库中木有,所以用PPA来下载。
sudo add-apt-repository ppa:xorg-edgers/ppa
sudo apt-get update
第四步:执行cuda的.run文件
cd到下载的.run文件夹执行:
sudo./cuda_7.5.18_linux.run--override
第五步:选择安装选项
选择安装选项:(注意:应为之前已经安装过NVIDIA Display Driver的驱动了(如第一步),所以这里选择不安装NVIDIA Accelerated Graphics Driver for Linux-x86_64 352.39。如果选择安装会出现错误,并且导致安装CUDA失败。
Do you accept the previously read EULA?(accept/decline/quit): accept
You are attempting to install on an unsupported configuration. Do you wish to continue?((y)es/(n)o) [ default is no ]: y
Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 352.39?((y)es/(n)o/(q)uit): n
Install the CUDA 7.5 Toolkit?((y)es/(n)o/(q)uit): y
Enter Toolkit Location [ default is/usr/local/cuda-7.5 ]:
Do you want to install a symbolic link at/usr/local/cuda?((y)es/(n)o/(q)uit): y
Install the CUDA 7.5 Samples?((y)es/(n)o/(q)uit): y
Enter CUDA Samples Location [ default is/home/kinghorn ]:/usr/local/cuda-7.5
Installing the CUDA Toolkit in/usr/local/cuda-7.5...
Finished copying samples.
===========
= Summary=
===========
Driver: Not Selected
Toolkit: Installed in/usr/local/cuda-7.5
Samples: Installed in/usr/local/cuda-7.5
第六步:添加cuda到环境变量里面
sudo nano/etc/profile.d/cuda.sh
export PATH=$PATH:/usr/local/cuda/bin
sudo nano/etc/ld.so.conf.d/cuda.conf
/usr/local/cuda/lib64
source/etc/ld.so.conf.d/cuda.confcd/usr/local/cuda-7.5/samples/1_Utilities/deviceQuery
make
sudo./deviceQuery
sudo ldconfig
第七步:将GCC降级或者采用暴力的方式让cuda7.5支持高版本GCC。
由于cuda7.5不支持gcc4.9以上的版本,而ubuntu16.04默认的是gcc5,这会造成安装的失败,解决方法有两种,
1、对gcc进行降级,让系统采用低版本的GCC,但是这种方式有一定的问题,因为Ubuntu16.04很多系统文件默认是使用gcc5编译的,因此如果用降级的方法安装完cuda后,在后期安装caffe的时候,可能会报类似于undefined的错误,这是因为你的gcc版本低,其所需的系统文件找不到。.
sudo apt-get install g++-4.9
sudo update-alternatives--install/usr/bin/gcc gcc/usr/bin/gcc-4.9 20
sudo update-alternatives--install/usr/bin/gcc gcc/usr/bin/gcc-5 10
sudo update-alternatives--install/usr/bin/g++ g++/usr/bin/g++-4.9 20
sudo update-alternatives--install/usr/bin/g++ g++/usr/bin/g++-5 10
sudo update-alternatives--install/usr/bin/cc cc/usr/bin/gcc 30
sudo update-alternatives--set cc/usr/bin/gcc
sudo update-alternatives--install/usr/bin/c++ c++/usr/bin/g++ 30
sudo update-alternatives--set c++/usr/bin/g++
2、这种方式有点类似于黑箱方式,即强制让他不报错。编辑/usr/local/cuda/include/host_config.h,将其中的第115行注释掉:
将
#error-- unsupported GNU version! gcc versions later than 4.9 are not supported!
改为
//#error-- unsupported GNU version! gcc versions later than 4.9 are not supported!
上面就是设置gcc版本优先级的。20和10就代表你所使用的gcc、g++的版本优先级。
第八步:测试是否安装成功
执行如下指令,正常情况下会出现设备中所有的GPU,并把每个GPU的信息打印出来。
nvidia-smi
如果没有出现错误之类的话,就说明安装成功了。
第九步:测试cuda的Samples
cd/usr/local/cuda-7.5/samples/1_Utilities/deviceQuery
make
sudo./deviceQuery
如果显示的是一些关于GPU的信息,则说明安装成功了。
Ubuntu 14.04安装配置CUDA
Ubuntu 12.04配置NVIDIA CUDA5.5实录
Ubuntu安装Theano+CUDA
关于Ubuntu 12.04下 CUDA5.5的安装请参看如下链接 Ubuntu 12.04安装 CUDA-5.5
Caffe配置简明教程( Ubuntu 14.04/ CUDA 7.5/ cuDNN 5.1/ OpenCV 3.1)
在Ubuntu 14.04上配置CUDA+Caffe+cuDNN+Anaconda+DIGITS
Ubuntu16.04下CUDA8.0+Caffe安装配置过程
Ubuntu 14.04下CUDA8.0+ cuDNN v5+ Caffe安装配置
Ubuntu 16.04+Nvidia GTX 1080+CUDA8.0深度学习环境配置
更多Ubuntu相关信息见Ubuntu专题页面