Ubuntu18.04安装CUDA10.2+Cudnn7.6.5+pytorch1.6.0+VTK8.2.0(持续更新中...

Ubuntu18.04卸载低版本N卡驱动+CUDA10.0+Cudnn7.4.2

安装CUDA10.2+Cudnn7.6.5+pytorch1.6.0+VTK8.2.0

运行pointnet++源码 从零开始搭建tensorflow环境看这里
ubuntu18.04+cuda10.0+cudnn7.4.2+anaconda3+tensorflow-gpu1.13.1

1.卸载原先安装好的显卡驱动:
sudo /usr/bin/nvidia-uninstall
2.查看显卡驱动是否卸载:
nvidia-smi
3.卸载Cuda10.0:
cd /usr/local/cuda/bin
sudo ./uninstall_cuda_10.0.pl
4.查看Cuda10.0是否卸载:
nvcc -V
5.卸载Cudnn7.4.2:
sudo rm -rf /usr/local/cuda/include/cudnn.h
sudo rm -rf /usr/local/cuda/lib64/libcudnn*
6.安装Cuda10.2(用cuda自带的选项安装显卡驱动):
sh cuda_10.2.89_440.33.01_linux.run
首先accept

CUDA Installer                                                                        │
│ - [X] Driver                                                                           │
│      [X] 440.33.01                                                                 │
│ + [X] CUDA Toolkit 10.2                                                  │
│   [X] CUDA Samples 10.2                                                │
│   [X] CUDA Demo Suite 10.2                                          │
│   [X] CUDA Documentation 10.2                                  │
│   Options                                                                               │
│   Install        

直接用向下键到Install处,回车,等待几分钟:

===========
= Summary =
===========
Driver:   Installed
Toolkit:  Installed in /usr/local/cuda-10.2/
Samples:  Installed in /home/yy, but missing recommended libraries

可以看到显卡驱动已经被安装,此时使用命令nvidia-smi查看:
Ubuntu18.04安装CUDA10.2+Cudnn7.6.5+pytorch1.6.0+VTK8.2.0(持续更新中..._第1张图片
此时说明显卡驱动已经安装好了,接下来配置环境变量:
gedit ~/.bashrc
将原来的添加的cuda10.0改为:

#添加cuda路径
export PATH="/usr/local/cuda-10.0/bin:$PATH"
export LD_LIBRARY_PATH="/usr/lcoal/cuda-10.0/lib64:$LD_LIBRARY_PATH"
#添加anaconda路径
export PATH="/home/yy/anaconda3/bin:$PATH"

改名字:

#添加cuda路径
export PATH="/usr/local/cuda-10.2/bin:$PATH"
export LD_LIBRARY_PATH="/usr/lcoal/cuda-10.2/lib64:$LD_LIBRARY_PATH"
#添加anaconda路径
export PATH="/home/yy/anaconda3/bin:$PATH"

修改完毕,点击保存,并生效:source ~/.bashrc
重启,再次进入ubuntu,测试cuda10.2是否安装成功:
cd /usr/local/cuda-10.2/samples/1_Utilities/deviceQuery
sudo make
./deviceQuery
看到最后结尾处:Result = PASS,代表cuda10.2安装成功:),开森!
可以使用nvcc -V查看cuda版本:

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Wed_Oct_23_19:24:38_PDT_2019
Cuda compilation tools, release 10.2, V10.2.89

7.安装cudnn7.6.5:
如果是cudnn-10.2-linux-x64-v7.6.5.32.solitairetheme8格式,先转成tgz格式再解压:
cp cudnn-10.2-linux-x64-v7.6.5.32.solitairetheme8 cudnn-10.2-linux-x64-v7.6.5.32.tgz
tar -xvf cudnn-10.2-linux-x64-v7.6.5.32.tgz
解压结果如下:

cuda/include/cudnn.h
cuda/NVIDIA_SLA_cuDNN_Support.txt
cuda/lib64/libcudnn.so
cuda/lib64/libcudnn.so.7
cuda/lib64/libcudnn.so.7.6.5
cuda/lib64/libcudnn_static.a

然后我们需要把cudnn移动到cuda中:
cp -P cuda/lib64/libcudnn* /usr/local/cuda-10.2/lib64/
cp cuda/include/cudnn.h /usr/local/cuda-10.2/include/
为所有用户设置读取权限(记得改成你自己的版本号!
chmod a+r /usr/local/cuda-10.2/include/cudnn.h
chmod a+r /usr/local/cuda-10.2/lib64/libcudnn*
查看cudnn版本信息:
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
结果如下:

#define CUDNN_MAJOR 7
#define CUDNN_MINOR 6
#define CUDNN_PATCHLEVEL 5
--
#define CUDNN_VERSION (CUDNN_MAJOR * 1000 + CUDNN_MINOR * 100 + CUDNN_PATCHLEVEL)

#include "driver_types.h"

OK,cudnn安装成功^ ^
8.安装pytorch1.6.0:
先进入pytorch官网下载对应版本:https://pytorch.org/
Ubuntu18.04安装CUDA10.2+Cudnn7.6.5+pytorch1.6.0+VTK8.2.0(持续更新中..._第2张图片
同时搭建虚拟环境,确保自己在root模式下!
创建环境:
conda create -n pytorch1.6.0 python=3.7
PS:如果要删除激活环境conda remove -n 环境名 --all
激活刚刚我们创建的环境:
source activate pytorch1.6.0
进入激活环境:
source activate pytorch1.6.0
使用官网给出的命令:
pip install torch==1.6.0 torchvision==0.7.0
太慢了…实在太慢了…大家都说科学上网,可是…太慢了,还是忍不住加豆瓣源:
pip install torch==1.6.0 torchvision==0.7.0 -i https://pypi.douban.com/simple(再次感叹豆瓣源好好用)
Ubuntu18.04安装CUDA10.2+Cudnn7.6.5+pytorch1.6.0+VTK8.2.0(持续更新中..._第3张图片
查看pytorch是否安装成功,是否能调用gpu加速:
Ubuntu18.04安装CUDA10.2+Cudnn7.6.5+pytorch1.6.0+VTK8.2.0(持续更新中..._第4张图片
OK,环境搭建完毕!
————————分割线————————
1.进入创建好的虚拟环境,运行xx源码,还需要安装pyqt5及相关依赖:
pip install pyqt5==5.12.0 -i https://pypi.douban.com/simple
apt install pyqt5*
apt install qt5-default qttools5-dev-tools
修改QT指向安装路径目录:
sudo gedit /usr/lib/aarch64-linux-gnu/qtchooser/default.conf
填入内容:

/usr/lib/qt5/bin
/usr/lib/aarch64-linux-gnu

将QT路径加入环境变量中:
gedit .bashrc

export QTDIR=/usr/lib/aarch64-linux-gnu/qt5
export PATH=$QTDIR/bin:$PATH
export LD_PLUGINS_PATH=$QTDIR/plugins:$LD_PLUGINS_PATH
export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH

生效文件:
source .bashrc
此时检查路径是否能正确读出:
echo $PATH
并查看版本信息:
qmake -v
Ubuntu18.04安装CUDA10.2+Cudnn7.6.5+pytorch1.6.0+VTK8.2.0(持续更新中..._第5张图片
2. 安装VTK库:
1)安装cmake:
官网下载地址:
https://cmake.org/download/
解压并进入cmake中bootstrap所在目录:
./bootstrap --qt-gui
Ubuntu18.04安装CUDA10.2+Cudnn7.6.5+pytorch1.6.0+VTK8.2.0(持续更新中..._第6张图片
编译:make -j8
Ubuntu18.04安装CUDA10.2+Cudnn7.6.5+pytorch1.6.0+VTK8.2.0(持续更新中..._第7张图片
安装:sudo make install
Ubuntu18.04安装CUDA10.2+Cudnn7.6.5+pytorch1.6.0+VTK8.2.0(持续更新中..._第8张图片

2)安装相关依赖:
sudo apt-get install mesa-common-dev
sudo apt-get install libgl1-mesa-dev
sudo apt install libqt5x11extras5-dev
sudo apt-get install cmake-curses-gui
下载VTK:
https://vtk.org/download/
接下来的过程参考:

pyqt+vtk点云渲染__记录 https://blog.csdn.net/Liyyeee/article/details/111824044

测试VTK:

python
import vtk

没有报错说明安装成功
3. 安装Laspy库:
pip install laspy -i https://pypi.douban.com/simple
4.运行main.py:
python main.py

你可能感兴趣的:(笔记,cuda,gpu,linux,pytorch,ubuntu)