Ubuntu18.04安装cuda8.0 遇到的问题及解决方案

一、gcc、g++版本过高

我的GCC、G++是6.5

sudo apt-get install gcc-4.8 g++-4.8

版本切换 

sudo update-alternatives --config gcc

我切换版本之后,显示切换到4.8,但是查看gcc\g++版本 gcc -v\g++ -v还是显示6.5

解决方法

利用ln -s 自己连接到对应的gcc\g++的文件夹解决问题。

示例

sudo ln -s /usr/bin/gcc-4.8 /usr/local/bin/gcc

如果还是不行,另一种方法

alias gcc='/usr/bin/gcc-4.8'
alias g++='/usr/bin/g++-4.8'

二、cannot find Toolkit in /usr/local/cuda-8.0

 

去官网下载cuda8.0,运行run文件安装,提示

cannot find Toolkit in /usr/local/cuda-8.0 

网上给出的方法有,大概有两种

第一种如下

sudo apt install nvidia-cuda-toolkit

不能解决我的问题。还是报同样的错误。

第二种,使用在线版的安装方式

wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_8.0.61-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu1604_8.0.61-1_amd64.deb
sudo apt-get update
sudo apt-get install cuda

 

通过在线安装的方式,提示cuda的一些依赖出错,也没有解决我的问题。

打开cuda的安装log,内容如下

Can't locate InstallUtils.pm in @INC (you may need to install the InstallUtils 
module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.26.1 
/usr/local/share/perl/5.26.1 /usr/lib/x86_64-linux-gnu/perl5/5.26 /usr/share/perl5
 /usr/lib/x86_64-linux-gnu/perl/5.26 /usr/share/perl/5.26 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at ./install-linux.pl line 6.

 解决方案

sh ./cuda*.run --tar mxvf #自己的cuda8.0文件
sudo cp InstallUtils.pm /usr/lib/x86_64-linux-gnu/perl-base
export $PERL5LIB

然后运行run文件,安装好了 

wangdyyy@wangdyyy-tuf-gaming:/usr/local$ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2016 NVIDIA Corporation
Built on Tue_Jan_10_13:22:03_CST_2017
Cuda compilation tools, release 8.0, V8.0.61

 

你可能感兴趣的:(Ubuntu18.04安装cuda8.0 遇到的问题及解决方案)