Manjaro Linux 安装GPU版本的tensorflow cuda cudnn教程

https://tensorflow.google.cn/install/source#linux  中文社区

Tensorflow CUDA及CUDNN版本对应关系表查询

https://tensorflow.google.cn/install/source#linux

安装此版本

下载Anaconda

sudo wget https://repo.anaconda.com/archive/Anaconda3-2019.03-Linux-x86_64.sh

执行安装

sh Anaconda3-2019.03-Linux-x86_64.sh

Manjaro Linux 安装GPU版本的tensorflow cuda cudnn教程_第1张图片

环境变量

cd /home/yangyang/anaconda3/
[yangyang@yangyangmanjaro anaconda3]$ echo 'export PATH ="/home/yangyang/anaconda3/bin:$PATH"' >> ~/.bashrc
[yangyang@yangyangmanjaro anaconda3]$ source ~/.bashrc

安装keras  我本来是测试conda 的 结果这个下载半天 还吧tensorflow 下载下来了  违背了初衷(在安装tensorflow之前不要安装)

conda install keras

 

开始安装tensorflow GPU版本

http://www.tensorfly.cn/tfdoc/get_started/os_setup.html

Linux 安装

安装 Bazel

首先依照 教程 安装 Bazel 的依赖. 然后使用下列命令下载和编译 Bazel 的源码:

https://github.com/bazelbuild/bazel

下载地址

https://docs.bazel.build/versions/master/install.html

 

查看系统架构和发行版本

我用的 Manjaro x86_64

uname -m && cat /etc/*release
x86_64
Manjaro Linux
DISTRIB_ID=ManjaroLinux
DISTRIB_RELEASE=18.0.4
DISTRIB_CODENAME=Illyria
DISTRIB_DESCRIPTION="Manjaro Linux"
Manjaro Linux
NAME="Manjaro Linux"
ID=manjaro
ID_LIKE=arch
PRETTY_NAME="Manjaro Linux"
ANSI_COLOR="1;32"
HOME_URL="https://www.manjaro.org/"
SUPPORT_URL="https://www.manjaro.org/"
BUG_REPORT_URL="https://bugs.manjaro.org/"
conda info
  active environment : base
    active env location : /home/yangyang/anaconda3
            shell level : 1
       user config file : /home/yangyang/.condarc
 populated config files : /home/yangyang/.condarc
          conda version : 4.6.11
    conda-build version : 3.17.8
         python version : 3.7.3.final.0
       base environment : /home/yangyang/anaconda3  (writable)
           channel URLs : https://repo.anaconda.com/pkgs/main/linux-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/free/linux-64
                          https://repo.anaconda.com/pkgs/free/noarch
                          https://repo.anaconda.com/pkgs/r/linux-64
                          https://repo.anaconda.com/pkgs/r/noarch
          package cache : /home/yangyang/anaconda3/pkgs
                          /home/yangyang/.conda/pkgs
       envs directories : /home/yangyang/anaconda3/envs
                          /home/yangyang/.conda/envs
               platform : linux-64
             user-agent : conda/4.6.11 requests/2.21.0 CPython/3.7.3 Linux/4.19.56-1-MANJARO manjaro/18.0.4 glibc/2.29
                UID:GID : 1000:1000
             netrc file : None
           offline mode : False

结果  linux 4.19.56-1-manjaro    python 3.7 环境

查看电脑的gcc版本

gcc -v
使用内建 specs。
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/9.1.0/lto-wrapper
目标:x86_64-pc-linux-gnu
配置为:/build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --with-system-zlib --with-isl --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --enable-gnu-indirect-function --enable-multilib --disable-werror --enable-checking=release --enable-default-pie --enable-default-ssp --enable-cet=auto
线程模型:posix
gcc 版本 9.1.0 (GCC) 

 

查询完之后  目前情况是   Gcc 9.1   linux 4.19   python 3.7

《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《

编译版本的安装 

一。 安装bazel 版本0.24.1版本

//但是我准备安装0.27.1最新版本//还是下次吧 这次还是0.24.1

https://github.com/bazelbuild/bazel/releases

https://github.com/bazelbuild/bazel/releases/tag/0.24.1

下载

wget https://github.com/bazelbuild/bazel/releases/download/0.24.1/bazel-0.24.1-installer-linux-x86_64.sh

镜像下载

https://mirror.bazel.build/openjdk/index.html

 wget https://mirror.bazel.build/openjdk/azul-zulu8.38.0.13-ca-jdk8.0.212/zulu8.38.0.13-ca-jdk8.0.212-linux_x64.tar.gz

解压

tar zxvf zulu8.38.0.13-ca-jdk8.0.212-linux_x64.tar.gz 

安装

 

 

 

安装nvidia驱动

https://www.nvidia.com/Download/index.aspx?lang=cn

 

 

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

 

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<,

安装已经编译好的版本 Tensorflow

安装cuda cuDNN  下载地址

https://developer.nvidia.com/cuda-downloads

搜索cuda

conda search cuda

No match found for: cuda. Search: *cuda*
# Name                       Version           Build  Channel             
cudatoolkit                      7.5               0  pkgs/free           
cudatoolkit                      7.5               2  pkgs/free           
cudatoolkit                      8.0               1  pkgs/free           
cudatoolkit                      8.0               3  pkgs/free           
cudatoolkit                      9.0      h13b8566_0  pkgs/main           
cudatoolkit                      9.2               0  pkgs/main           
cudatoolkit                 10.0.130               0  pkgs/main           
cudatoolkit                 10.1.168               0  pkgs/main           
numbapro_cudalib                 0.1               0  pkgs/free           
numbapro_cudalib                 0.2               0  pkgs/free 

conda search cuDNN

conda search cuDNN
WARNING: The conda.compat module is deprecated and will be removed in a future release.
Loading channels: done
# Name                       Version           Build  Channel             
cudnn                            5.1               0  pkgs/free           
cudnn                         5.1.10       cuda7.5_0  pkgs/free           
cudnn                         5.1.10       cuda8.0_0  pkgs/free           
cudnn                            6.0               0  pkgs/free           
cudnn                         6.0.21       cuda7.5_0  pkgs/free           
cudnn                         6.0.21       cuda8.0_0  pkgs/free           
cudnn                          7.0.5       cuda8.0_0  pkgs/main           
cudnn                          7.1.2       cuda9.0_0  pkgs/main           
cudnn                          7.1.3       cuda8.0_0  pkgs/main           
cudnn                          7.2.1       cuda9.2_0  pkgs/main           
cudnn                          7.3.1      cuda10.0_0  pkgs/main           
cudnn                          7.3.1       cuda9.0_0  pkgs/main           
cudnn                          7.3.1       cuda9.2_0  pkgs/main           
cudnn                          7.6.0      cuda10.0_0  pkgs/main           
cudnn                          7.6.0      cuda10.1_0  pkgs/main           
cudnn                          7.6.0       cuda9.0_0  pkgs/main           
cudnn                          7.6.0       cuda9.2_0  pkgs/main    

安装non-free驱动

查询显卡驱动

inxi -G
Graphics:  Device-1: Intel HD Graphics 630 driver: i915 v: kernel 
           Device-2: NVIDIA GK208B [GeForce GT 710] driver: nouveau v: kernel 
           Display: x11 server: X.org 1.20.5 driver: nouveau 
           resolution:  
           OpenGL: renderer: Mesa DRI Intel HD Graphics 630 (Kaby Lake GT2) 
           v: 4.5 Mesa 19.1.1 

https://blog.csdn.net/qq_39828850/article/details/87919188

参考博客

查询tensorflow 版本

conda search tensorflow
WARNING: The conda.compat module is deprecated and will be removed in a future release.
Loading channels: done
# Name                       Version           Build  Channel             
tensorflow                 0.10.0rc0     np111py27_0  pkgs/free           
tensorflow                 0.10.0rc0     np111py34_0  pkgs/free           
tensorflow                 0.10.0rc0     np111py35_0  pkgs/free           
tensorflow                     1.0.1     np112py27_0  pkgs/free           
tensorflow                     1.0.1     np112py35_0  pkgs/free           
tensorflow                     1.0.1     np112py36_0  pkgs/free           
tensorflow                     1.1.0     np111py27_0  pkgs/free           
tensorflow                     1.1.0     np111py35_0  pkgs/free           
tensorflow                     1.1.0     np111py36_0  pkgs/free           
tensorflow                     1.1.0     np112py27_0  pkgs/free           
tensorflow                     1.1.0     np112py35_0  pkgs/free           
tensorflow                     1.1.0     np112py36_0  pkgs/free           
tensorflow                     1.2.1          py27_0  pkgs/free           
tensorflow                     1.2.1          py35_0  pkgs/free           
tensorflow                     1.2.1          py36_0  pkgs/free           
tensorflow                     1.3.0               0  pkgs/free           
tensorflow                     1.4.1               0  pkgs/main           
tensorflow                     1.5.0               0  pkgs/main           
tensorflow                     1.6.0               0  pkgs/main           
tensorflow                     1.7.0               0  pkgs/main           
tensorflow                     1.8.0      h01c6a4e_0  pkgs/main           
tensorflow                     1.8.0      h16da8f2_0  pkgs/main           
tensorflow                     1.8.0      h2742514_0  pkgs/main           
tensorflow                     1.8.0      h469b60b_0  pkgs/main           
tensorflow                     1.8.0      h57681fa_0  pkgs/main           
tensorflow                     1.8.0      h5c3c37f_0  pkgs/main           
tensorflow                     1.8.0      h645107b_0  pkgs/main           
tensorflow                     1.8.0      h7b2774c_0  pkgs/main           
tensorflow                     1.8.0      hb11d968_0  pkgs/main           
tensorflow                     1.8.0      hb1b1514_0  pkgs/main           
tensorflow                     1.8.0      hb381393_0  pkgs/main           
tensorflow                     1.8.0      hc2d9325_0  pkgs/main           
tensorflow                     1.9.0 eigen_py27hf386fcc_1  pkgs/main           
tensorflow                     1.9.0 eigen_py35h8c89287_1  pkgs/main           
tensorflow                     1.9.0 eigen_py36h8c89287_0  pkgs/main           
tensorflow                     1.9.0 eigen_py36hbec2359_0  pkgs/main           
tensorflow                     1.9.0 eigen_py36hbec2359_1  pkgs/main           
tensorflow                     1.9.0 eigen_py36hf386fcc_0  pkgs/main           
tensorflow                     1.9.0 gpu_py27h233f449_1  pkgs/main           
tensorflow                     1.9.0 gpu_py27h395d940_1  pkgs/main           
tensorflow                     1.9.0 gpu_py27hd3a791e_1  pkgs/main           
tensorflow                     1.9.0 gpu_py35h42d5ad8_1  pkgs/main           
tensorflow                     1.9.0 gpu_py35h60c0932_1  pkgs/main           
tensorflow                     1.9.0 gpu_py35hb39db67_1  pkgs/main           
tensorflow                     1.9.0 gpu_py36h02c5d5e_1  pkgs/main           
tensorflow                     1.9.0 gpu_py36h220e158_1  pkgs/main           
tensorflow                     1.9.0 gpu_py36h313df88_1  pkgs/main           
tensorflow                     1.9.0 mkl_py27h0cb61a4_1  pkgs/main           
tensorflow                     1.9.0 mkl_py35h5be851a_1  pkgs/main           
tensorflow                     1.9.0 mkl_py36h0cb61a4_0  pkgs/main           
tensorflow                     1.9.0 mkl_py36h5be851a_0  pkgs/main           
tensorflow                     1.9.0 mkl_py36h6d6ce78_0  pkgs/main           
tensorflow                     1.9.0 mkl_py36h6d6ce78_1  pkgs/main           
tensorflow                    1.10.0 eigen_py27ha0ab958_0  pkgs/main           
tensorflow                    1.10.0 eigen_py35h5ed898b_0  pkgs/main           
tensorflow                    1.10.0 eigen_py36hb995bb4_0  pkgs/main           
tensorflow                    1.10.0 gpu_py27h67ad7fe_0  pkgs/main           
tensorflow                    1.10.0 gpu_py27h6f941b3_0  pkgs/main           
tensorflow                    1.10.0 gpu_py27h9580370_0  pkgs/main           
tensorflow                    1.10.0 gpu_py35h566a776_0  pkgs/main           
tensorflow                    1.10.0 gpu_py35ha6119f3_0  pkgs/main           
tensorflow                    1.10.0 gpu_py35hd9c640d_0  pkgs/main           
tensorflow                    1.10.0 gpu_py36h8dbd23f_0  pkgs/main           
tensorflow                    1.10.0 gpu_py36h97a2126_0  pkgs/main           
tensorflow                    1.10.0 gpu_py36hcebf108_0  pkgs/main           
tensorflow                    1.10.0 mkl_py27h857755f_0  pkgs/main           
tensorflow                    1.10.0 mkl_py35heddcb22_0  pkgs/main           
tensorflow                    1.10.0 mkl_py36hdb377fd_0  pkgs/main           
tensorflow                    1.11.0 eigen_py27h06aee4b_0  pkgs/main           
tensorflow                    1.11.0 eigen_py36he3f7ef1_0  pkgs/main           
tensorflow                    1.11.0 gpu_py27h99ab47f_0  pkgs/main           
tensorflow                    1.11.0 gpu_py27hd8bfc1a_0  pkgs/main           
tensorflow                    1.11.0 gpu_py36h4459f94_0  pkgs/main           
tensorflow                    1.11.0 gpu_py36h9c9050a_0  pkgs/main           
tensorflow                    1.11.0 mkl_py27h25e0b76_0  pkgs/main           
tensorflow                    1.11.0 mkl_py36ha6f0bda_0  pkgs/main           
tensorflow                    1.12.0 eigen_py27hfe19c55_0  pkgs/main           
tensorflow                    1.12.0 eigen_py36hbd5f568_0  pkgs/main           
tensorflow                    1.12.0 gpu_py27h2a0f108_0  pkgs/main           
tensorflow                    1.12.0 gpu_py27h956c076_0  pkgs/main           
tensorflow                    1.12.0 gpu_py36he68c306_0  pkgs/main           
tensorflow                    1.12.0 gpu_py36he74679b_0  pkgs/main           
tensorflow                    1.12.0 mkl_py27hc55d17a_0  pkgs/main           
tensorflow                    1.12.0 mkl_py36h69b6ba0_0  pkgs/main           
tensorflow                    1.13.1 eigen_py27h5e92bea_0  pkgs/main           
tensorflow                    1.13.1 eigen_py36hc59b85e_0  pkgs/main           
tensorflow                    1.13.1 eigen_py37h7cb7401_0  pkgs/main           
tensorflow                    1.13.1 gpu_py27hc5faae7_0  pkgs/main           
tensorflow                    1.13.1 gpu_py27hcb41dfa_0  pkgs/main           
tensorflow                    1.13.1 gpu_py27hd3b962e_0  pkgs/main           
tensorflow                    1.13.1 gpu_py36h26cf82e_0  pkgs/main           
tensorflow                    1.13.1 gpu_py36h3991807_0  pkgs/main           
tensorflow                    1.13.1 gpu_py36h9b25d83_0  pkgs/main           
tensorflow                    1.13.1 gpu_py37h49933a4_0  pkgs/main           
tensorflow                    1.13.1 gpu_py37hc158e3b_0  pkgs/main           
tensorflow                    1.13.1 gpu_py37hd37c573_0  pkgs/main           
tensorflow                    1.13.1 mkl_py27h74ee40f_0  pkgs/main           
tensorflow                    1.13.1 mkl_py36h27d456a_0  pkgs/main           
tensorflow                    1.13.1 mkl_py37h54b294f_0  pkgs/main           
tensorflow                    1.14.0 eigen_py27h99c1539_0  pkgs/main           
tensorflow                    1.14.0 eigen_py36hb2cf719_0  pkgs/main           
tensorflow                    1.14.0 eigen_py37h195cb1b_0  pkgs/main           
tensorflow                    1.14.0 mkl_py27h957988d_0  pkgs/main           
tensorflow                    1.14.0 mkl_py36h2526735_0  pkgs/main           
tensorflow                    1.14.0 mkl_py37h45c423b_0  pkgs/main           

安装cuda 10.0.130

conda install cudatoolkit==10.0.130

安装cuDNN7.6.0

conda install cudnn==7.6.0

安装tensorflow 1.31..1 gpu-py37hd27c573_0    tensorflow                    1.13.1 gpu_py37hd37c573_0

conda install tensorflow-gpu==1.13.1

做copy 代码只是示例

解压并拷贝 CUDNN 文件到 Cuda Toolkit 7.0 安装路径下. 假设 Cuda Toolkit 7.0 安装 在 /usr/local/cuda, 执行以下命令:

tar xvzf cudnn-6.5-linux-x64-v2.tgz
sudo cp cudnn-6.5-linux-x64-v2/cudnn.h /usr/local/cuda/include
sudo cp cudnn-6.5-linux-x64-v2/libcudnn* /usr/local/cuda/lib64

 

测试

验证失败  因为驱动没搞定

 

 

 

 

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

 

 

 

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

 conda 安装tensorflow CPU版本

Manjaro Linux 安装GPU版本的tensorflow cuda cudnn教程_第2张图片

conda create -n tensorflow_cpu

激活 conda activate tensorflow_cpu                            推出  conda deactivate tensorflow_cpu

conda install tensorflow==1.14.0

验证  OK

Manjaro Linux 安装GPU版本的tensorflow cuda cudnn教程_第3张图片

 

anaconda-navigator 启动界面检查一下环境

 

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

 

安装pyCharm

Manjaro Linux 安装GPU版本的tensorflow cuda cudnn教程_第4张图片

PyCharm does not have write access to /usr/share/pycharm. Please run it by a privileged user to update

Manjaro Linux 安装GPU版本的tensorflow cuda cudnn教程_第5张图片

修改写入权限就可以了

sudo chown -R $USER:$USER /usr/share/pycharm

 

 

你可能感兴趣的:(tensorflow,manjaro)