GPU:GeForce840M
显卡驱动:预装,版本390
笔记本
1.降级gcc 使用gcc5
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-5 g++-5
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 60 --slave /usr/bin/g++ g++ /usr/bin/g++-5
2安装python3.7
sudo apt update
sudo apt upgrade -y
sudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install python3.7 -y
sudo rm -rf /usr/bin/python3
sudo ln -s /usr/bin/python3.7 /usr/bin/python3
查找python位置
which python
3.安装n卡驱动
第一种:
1. 更新apt-get源列表
sudo apt-get update
sudo apt-get upgrade
2. 添加驱动源
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update
sudo apt install nvidia-driver-410
sudo sh *.run
如果驱动是独立安装了,一定要选择不安装驱动!选择如下:
有如下信息 可以忽略:
***WARNING: Incomplete installation! This installation did not install the CUDA Driver. A driver of version at least 384.00 is required for CUDA 10.0 functionality to work.
To install the driver using this installer, run the following command, replacing with the name of this run file:
4.添加环境变量
sudo gedit ~/.bashrc
添加到最后
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
5.测试是否成功
sudo rm -rf /usr/local/cuda
sudo ln -s /usr/local/cuda-10.0 /usr/local/cuda
nvcc --version
cd /usr/local/cuda/samples/1_Utilities/deviceQuery
sudo make
./deviceQuery
第二种:
sudo add-apt-repository ppa:graphics-drivers
sudo apt-get update
ubuntu-drivers devices
如果系统中有老版本显卡驱动,要先卸载
sudo apt-get remove --purge nvidia*
sudo ubuntu-drivers autoinstall
#这里我安装了430,你可以选择其他的
sudo apt-get install nvidia-430
重启
#输入
nvidia-smi
sudo sh cuda_10.1.105_418.39_linux.run
sudo vim ~/.bashrc
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 rm -rf /usr/local/cuda
sudo ln -s /usr/local/cuda-10.0 /usr/local/cuda
nvcc --version
cd /usr/local/cuda/samples/1_Utilities/deviceQuery
sudo make
./deviceQuery
这样的结果就ok 下边有个pass
在去官网找linux 的cudnn https://developer.nvidia.com/rdp/cudnn-download
下载完成后,输入以下命令解压文件
tar -zxvf cudnn-10.1-linux-x64-v7.5.1.10.tgz
sudo cp cuda/include/cudnn.h /usr/local/cuda/include/ #解压后的文件夹名为cuda
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64/
sudo chmod a+r /usr/local/cuda/include/cudnn.h #增加所有用户对文件的可执行权限
sudo chmod a+r /usr/local/cuda/lib64/libcudnn*
查看cudnn 版本
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
至此安装结束
可以玩玩tensorflow-gpu了
希望能交流更多技术,关注小白的微信公众号吧。