安装驱动
#----------------
https://blog.csdn.net/dihuanlai9093/article/details/79253963/
sudo gedit /etc/modprobe.d/blacklist.conf
然后按键盘上的字母 i 进入编辑模式,并在最后添加下面两行
blacklist nouveau
options nouveau modeset = 0
按Esc键退出编辑模式,再输入下面的命令,回车,保存退出。
:wq
然后输入
sudo ldconfig
sudo update-initramfs -u
验证是否成功禁用nouveau
sudo lspci | grep nouveau
如果没有内容显示,则禁用成功。
Downloas the public drivers
sudo apt-get remove --purge nvidia*
Ctrl-Alt+F1
sudo chmod a+x NVIDIA-Linux-x86_64-375.20.run
sudo service lightdm stop
sudo ./NVIDIA-Linux-x86_64-375.20.run -no-x-check -no-nouveau-check -no-opengl-files
sudo service lightdm start
------------------------------------
test
dmic@dmic:~$ nvidia-smi
---------------------------------
Tue Nov 26 08:42:25 2019
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 440.36 Driver Version: 440.36 CUDA Version: 10.2 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 TITAN Xp Off | 00000000:01:00.0 Off | N/A |
| 16% 33C P0 55W / 250W | 0MiB / 12196MiB | 0% Default |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| No running processes found |
+-----------------------------------------------------------------------------+
安装 CUDA
下载CUDA_8.0(https://developer.nvidia.com/cuda-toolkit-archive)
sudo sh cuda_8.0.61_375.26_linux.run (accept,no(Driver),yes,yes,..........)(在选择安装驱动时候选no,之前已经安装了驱动,按空格跳过more)
sudo sh cuda_8.0.61.2_linux.run (安装补丁)
$ls -all(显示所有文件包括隐藏的)
sudo vim ~/.bashrc
在.bashrc文件里面编写:
export PATH=/usr/local/cuda-8.0/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64:$LD_LIBRARY_PATH
保存并退出
source ~/.bashrc
安装cudnn
下载cudnn_6.0(https://developer.nvidia.com/cudnn)第一次下载需要注册
下载完毕后,切到默认的Downloads文件夹,可以看到 cudnn 压缩包
先解压,然后 复制解压后的cuDNN内容到cuda相关文件夹内
sudo cp -r ~/Downloads/cuda /usr/local/cuda-8.0
解压下载的文件,可以看到cuda文件夹,在下载的目录下打开终端,执行如下命令:
$~Download:sudo cp cuda/include/cudnn.h /usr/local/cuda/include/
$~Download: sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64/
$~Download:sudo chmod a+r /usr/local/cuda/include/cudnn.h
$~Download:sudo chmod a+r /usr/local/cuda/lib64/libcudnn*
建立软链接
cd /usr/local/cuda/lib64/
sudo rm -rf libcudnn.so libcudnn.so.6
sudo ln -s libcudnn.so.6.0.21 libcudnn.so.6
sudo ln -s libcudnn.so.6 libcudnn.so
安装Vim,终端输入:
sudo apt-get install vim
sudo vim /etc/ld.so.conf.d/cuda.conf
键盘按i进入编辑状态,添加文字:
/usr/local/cuda/lib64
终端下输入sudo ldconfig -v命令查看是否链接成功,是否有/usr/local/cuda/lib64文件夹
测试
终端输入
(验证CUDA)
$:cd /usr/local/cuda-8.0/samples/1_Utilities/deviceQuery
sudo make
./deviceQuery
验证cudnn
nvcc -V
cuda版本
cat /usr/local/cuda/version.txt
cudnn版本
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
安装Anaconda3 for theano
download anaconda(https://www.anaconda.com/distribution/)
sudo bash Anaconda3-2018.12-Linux-x86_64.sh
在终端输入Python发现依然是gnome自带的python版本,这是因为.bashrc的更新还没有生效,命令行输入:source ~/.bashrc
conda install theano
报错,无权限,又不可再前面添加sudo
sudo chmod -R 777 anaconda3
conda install theano
vim .theanorc
编辑
[global]
floatX=float32
device=cuda
root=/usr/local/cuda-8.0
[nvcc]
fastmath=True
optimizer_including=cudnn
[blas]
ldflags=-lopenblas
[dnn.conv]
algo_bwd_filter=deterministic
algo_bwd_data=deterministic
[cuda]
root=/usr/local/cuda-8.0
安装pygpu
conda install pygpu(版本0.7.6)