当前位置:   article > 正文

Ubuntu16.04下安装多版本cuda和cudnn_ubuntu 安装多版本cuda cudnn

ubuntu 安装多版本cuda cudnn

 i7-7700k + TITAN X + 16G DDR4 2400 + 256G SSD

ubuntu16.0.4+ anaconda3+ tensorflow-gpu(0.12.1)   

电脑已经安装CUDA9+ cuDNN7.1, 本次安装CUDA8.0.44 + cuDNN5.1

相关命令:

查看cuda版本 :      nvcc -V

查看位置  :            which nvcc

查看NVIDIA动态使用情况:  watch -n 1 nvidia-smi  

cuda 版本    :    cat /usr/local/cuda/version.txt

cudnn 版本  :    cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2

NVIDIA 驱动版本  :  cat /proc/driver/nvidia/version

查看环境变量  :           env

LD_DEBUG=all cat

卸载cuda :                 sudo  /usr/local/cuda-8.0/bin/uninstall_cuda_8.0.pl

卸载NVIDIA Driver :   sudo  /usr/bin/nvidia-uninstall

多版本CUDA切换:

sudo  rm  -rf  /usr/local/cuda                   

sudo  ln  -s    /usr/local/cuda-8.0   /usr/local/cuda  

sudo  ln  -s    /usr/local/cuda-9.1   /usr/local/cuda   

查看目录属性:    ls -l 目录名

具有管理员权限的文件管理器, 比如移动文件夹 :   sudo nautilus 

加入-R 参数,将权限传递给子文件夹 :   chmod -R  777  /home/mypackage

**********************************************************************************************************

GitHub上下了个程序,tensorflow-gpu=0.12,gpu下跑报错,应该是CUDA版本高了

  1. E tensorflow/stream_executor/cuda/cuda_dnn.cc:378] Loaded runtime CuDNN library: 7103 (compatibility version 7100) but source was compiled with 5105 (compatibility version 5100). If using a binary install, upgrade your CuDNN library to match. If building from sources, make sure the library loaded at runtime matches a compatible version specified during compile configuration.
  2. E tensorflow/stream_executor/cuda/cuda_dnn.cc:378] Loaded runtime CuDNN library: 7103 (compatibility version 7100) but source was compiled with 5105 (compatibility version 5100). If using a binary install, upgrade your CuDNN library to match. If building from sources, make sure the library loaded at runtime matches a compatible version specified during compile configuration.
  3. F tensorflow/core/kernels/conv_ops.cc:532] Check failed: stream->parent()->GetConvolveAlgorithms(&algorithms)
  4. F tensorflow/core/kernels/conv_ops.cc:532] Check failed: stream->parent()->GetConvolveAlgorithms(&algorithms)

Ubuntu16.04下安装多版本cuda和cudnn_AscentOf的博客-CSDN博客_cuda多版本安装    :Ubuntu16.04下安装多版本cuda和cudnn

Ubuntu16.04下同时安装CUDA8.0和CUDA7.0_Rosun_的博客-CSDN博客                :Ubuntu16.04下同时安装CUDA8.0和CUDA7.0

https://blog.csdn.net/maple2014/article/details/78574275                :安装多版本 cuda ,多版本之间切换

https://blog.csdn.net/mumoDM/article/details/79462604                 :多版本CUDA问题

Windows Tensorflow GPU安装_ChainingBlocks的博客-CSDN博客                :windows下tensorflow-gpu安装

      0、 Tensorflow gpu 官方安装指南:

           https://www.tensorflow.org/install/install_windows 

  1. 下载CUDA并安装: 
    各个版本的CUDA :CUDA Toolkit Archive | NVIDIA Developer

  2. 下载CUDNN  (要注册)
    CUDNN库下载地址:NVIDIA cuDNN | NVIDIA Developer   

Installation Guide for Linux :  cuda_8.0.44(官方安装说明) cuda_8.0.44

安装CUDA8.0和cuDNN5.1:

Ubuntu16.04下安装cuda和cudnn的三种方法(亲测全部有效)_老王回归的博客-CSDN博客_ubuntu安装cuda

Ubuntu下安装CUDA8.0及nvidia驱动(详细教程)_autotian的博客-CSDN博客_cuda8.0

下载好后直接命令行解压然后复制 lib64 和 include 文件夹到  usr/local/cuda-8.0,命令如下:

  1. # Installing from a Tar Filetar -zxvf 压缩文件名.tar.gz
  2. sudo cp cuda/include/cudnn.h /usr/local/cuda-8.0/include
  3. sudo cp cuda/lib64/libcudnn* /usr/local/cuda-8.0/lib64
  4. sudo chmod a+r /usr/local/cuda-8.0/include/cudnn.h
  5. sudo chmod a+r /usr/local/cuda-8.0/lib64/libcudnn*

cuda版本切换

gedit ~/.bashrc             #更改 ~/.bashrc 文件,添加两行

  1. export PATH=/usr/local/cuda/bin${PATH:+:${PATH}}
  2. export LD_LIBRARY_PATH=/usr/local/cuda/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
下面的不行:
  1. export PATH="$PATH:/usr/local/cuda/bin"
  2. export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64/"

sudo /etc/profile    #必须更改/etc/profile 文件, 而且更改后必须重启计算机才有效 (source /etc/profile 不能生效)

  1. export PATH=/usr/local/cuda-9.1/bin:$PATH
  2. export LD_LIBRARY_PATH=/usr/local/cuda-9.1/lib64:$LD_LIBRARY_PATH

改为:

  1. export PATH=/usr/local/cuda/bin:$PATH
  2. export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH

从cuda9.1切换到cuda8.0
  1. sudo rm -rf /usr/local/cuda                    #删除之前创建的软链接
  2. sudo ln -s /usr/local/cuda-8.0 /usr/local/cuda #创建新 cuda 的软链接

从cuda8.0切换到cuda9.0sudo rm -rf /usr/local/cuda                       #删除之前创建的软链接sudo ln -s /usr/local/cuda-9.1  /usr/local/cuda   #创建新 cuda 的软链接

可以用命令来查看cuda是否切换完成:

  1. $ nvcc --version
  2. nvcc: NVIDIA (R) Cuda compiler driver
  3. Copyright (c) 2005-2017 NVIDIA Corporation
  4. Built on Fri_Sep__1_21:08:03_CDT_2017
  5. Cuda compilation tools, release 9.0, V9.0.176
which nvcc :查看nvcc位置
CUDA8.0+cuDNN5.1 未完全安装:

  1. Installing the CUDA Toolkit in /usr/local/cuda-8.0 ...
  2. Installing the CUDA Samples in /home/human-machine ...
  3. Copying samples to /home/human-machine/NVIDIA_CUDA-8.0_Samples now...
  4. Finished copying samples.
  5. ===========
  6. = Summary =
  7. ===========
  8. Driver: Not Selected
  9. Toolkit: Installed in /usr/local/cuda-8.0
  10. Samples: Installed in /home/human-machine
  11. Please make sure that
  12. - PATH includes /usr/local/cuda-8.0/bin
  13. - LD_LIBRARY_PATH includes /usr/local/cuda-8.0/lib64, or, add /usr/local/cuda-8.0/lib64 to /etc/ld.so.conf and run ldconfig as root
  14. To uninstall the CUDA Toolkit, run the uninstall script in /usr/local/cuda-8.0/bin
  15. Please see CUDA_Installation_Guide_Linux.pdf in /usr/local/cuda-8.0/doc/pdf for detailed information on setting up CUDA.
  16. ***WARNING: Incomplete installation! This installation did not install the CUDA Driver. A driver of version at least 361.00 is required for CUDA 8.0 functionality to work.
  17. To install the driver using this installer, run the following command, replacing <CudaInstaller> with the name of this run file:
  18. sudo <CudaInstaller>.run -silent -driver
  19. Logfile is /tmp/cuda_install_1534.log

#编译并测试设备 deviceQuery:  
切换到例子存放的路径,默认路径是 ~/NVIDIA_CUDA-7.5_Samples ,切换到相应路径
然后终端输入:$  make
运行编译生成的二进制文件
编译后的二进制文件, 默认存放在 ~/NVIDIA_CUDA-7.5_Samples/bin 
切换路径 :$  cd  /NVIDIA_CUDA-8.0_Samples/bin/x86_64/linux/release 
终端输入 :$  ./deviceQuery

 #编译并测试带宽 bandwidthTest:  
     cd ../bandwidthTest  
     sudo make  
     ./bandwidthTest  
如果这两个测试的最后结果都是Result = PASS,说明CUDA安装成功

CUDA8.0+cuDNN5.1报错,但tensorflow-gpu可以跑,tensorboard也可以用。

  1. human-machine@humanmachine-System-Product-Name:~/NVIDIA_CUDA-8.0_Samples$ make
  2. make[1]: Entering directory '/home/human-machine/NVIDIA_CUDA-8.0_Samples/0_Simple/simpleVoteIntrinsics_nvrtc'
  3. find: `/usr/local/cuda-8.0/lib64/stubs': 没有那个文件或目录
  4. >>> WARNING - libcuda.so not found, CUDA Driver is not installed. Please re-install the driver. <<<
  5. [@] g++ -I../../common/inc -I/usr/local/cuda-8.0/include -o simpleVoteIntrinsics.o -c simpleVoteIntrinsics.cpp
  6. [@] g++ -L/usr/local/cuda-8.0/lib64 -L/usr/local/cuda-8.0/lib64/stubs -o simpleVoteIntrinsics_nvrtc simpleVoteIntrinsics.o -lcuda -lnvrtc
  7. [@] mkdir -p ../../bin/x86_64/linux/release
  8. [@] cp simpleVoteIntrinsics_nvrtc ../../bin/x86_64/linux/release
  9. make[1]: Leaving directory '/home/human-machine/NVIDIA_CUDA-8.0_Samples/0_Simple/simpleVoteIntrinsics_nvrtc'
  10. make[1]: Entering directory '/home/human-machine/NVIDIA_CUDA-8.0_Samples/0_Simple/matrixMul'
  11. "/usr/local/cuda-8.0"/bin/nvcc -ccbin g++ -I../../common/inc -m64 -gencode arch=compute_20,code=sm_20 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_37,code=sm_37 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_60,code=compute_60 -o matrixMul.o -c matrixMul.cu
  12. nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
  13. cc1plus: fatal error: cuda_runtime.h: 没有那个文件或目录
  14. compilation terminated.
  15. Makefile:250: recipe for target 'matrixMul.o' failed
  16. make[1]: *** [matrixMul.o] Error 1
  17. make[1]: Leaving directory '/home/human-machine/NVIDIA_CUDA-8.0_Samples/0_Simple/matrixMul'
  18. Makefile:52: recipe for target '0_Simple/matrixMul/Makefile.ph_build' failed
  19. make: *** [0_Simple/matrixMul/Makefile.ph_build] Error 2

CUDA9.1+cuDNN7.1 编译测试正常:

Ubuntu 14.04 上安装 CUDA 7.5/8.0 超详细教程_服务器应用_Linux公社-Linux系统门户网站       :参考官方文档,干货
ubuntu 同时安装cuda8.0与cuda9.0,cuda9.1_七爷OK的博客-CSDN博客
Ubuntu16.04搭建GTX1080+CUDA9.0+cuDNN7.0.4+Tensorflow1.6.0环境

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/146122
推荐阅读
相关标签
  

闽ICP备14008679号