为了编写能够在2080显卡机器上运行程序,将本机的环境配置为cuda10.0,cudnn7.3.1和Tensorflow1.13.1
一、卸载原有的显卡驱动,安装cuda10所需要的显卡驱动。
(1)按ctrl+alt+f1进入命令行界面,输入
sudo service lightdm stop
将图形界面关闭。
(2)然后卸载掉原有390的驱动:
sudo apt-get remove nvidia-*
(3)安装新的显卡驱动。
在你的显卡驱动所在目录下输入
sudo sh NVIDIA-Linux-x86_64-410.73.run
(4)安装过程中的选项。
The distribution-provided pre-install script failed! Are you sure you want to continue? 选择 yes 继续。
Would you like to register the kernel module souces with DKMS? This will allow DKMS to automatically build a new module, if
you install a different kernel later? 选择 No 继续。
(ru shangtu )Would you like to sign the NVIDIA kernel modul?选择:install without signing
gcc version 不匹配 选中 ignore gcc version
Installing Nvidia's 32-bit compatibility libraries? 选择 No 继续
Would you like to run the nvidia-xconfigutility to automatically update your x configuration so that the NVIDIA x driver will be
used when you restart x? Any pre-existing x confile will be backed up. 选择 Yes 继续
若在过程中出现gcc版本问题,请参考gcc在线更换版本或者gcc离线版本替换
若在上述过程中遇见以下问题,是属于nouveau驱动未禁用导致的,禁用之后清空所有显卡驱动再重新安装即可。
禁用nouveau
在root权限下执行以下代码:
i)打开该文件
vi /etc/modprobe.d/blacklist-nouveau.conf
在其中添加两行
blacklist nouveau
options nouveau modeset=0
然后执行
update-initramfs -u
接着重启
reboot
最后验证是否禁用
lsmod | grep nouveau
若禁用成功
是什么也不会显示的
(5)挂载显卡驱动
modprobe nvidia
(6)检查驱动是否安装成功
nvidia-smi
若出现以下提示代表安装成功。
(7)sudo reboot 重启。
二、安装cuda10
参考以下链接安装cuda10,但是不用进行环境配置。
三、配置环境让两者共存,在命令行输入
sudo gedit /etc/profile
将文件末尾修改为如下所示,
然后保存关闭输入 一下命令,使环境生效。
source /etc/profile
将环境变量保存,重启即可使用cuda10,想要使用哪个就将另一个cuda注销,使环境生效,重启就可以使用。
四、安装cudnn
在存储有cudnn的三个文件下打开终端输入:
dpkg -i -*
即可安装成功。
五、安装Tensorflow
参考一下链接安装tensorflow虚拟环境。与之前共存。
六、验证
使用nvcc -V只能显示之前的cuda8.0,并不能表明cuda10.0没有安装成功。
激活cuda10的tensorflow环境,输入Python进行验证。
安装成功!
假设没有安装成功cudnn,出现libcudart.so.10.0的问题。
1.去检查一下/usr/local/cuda/include/中是否含有cudnn.h的文件,没有的话从/usr/include中拷贝一份。
2.再检查/usr/local/cuda/lib64/中的libcudnn*的文件是否存在,不存在的话从/usr/lib中拷贝一份。
出现以上问题可能是因为没有在安装cudnn之前配置cuda的环境而导致的。