Ubuntu 18.04 CUDA10.1 Anaconda 安装tensorflow-gpu 1.13.1

由于想使用https://github.com/matterport/Mask_RCNN

这个代码使用的是比较老版本的tensorflow 对应的cuda版本是10.0或9.0或9.2,我系统安装的cuda是10.1版本

cudatoolkit是库不是驱动,库意味着不是必须安装到系统目录,可以安装到用户目录,具体链接哪些库,怎么链接由Makefile决定,可执行文件执行的时候,在LD_LIBRARY_PATH路径或其他路径里能找到需要的库文件即可。

查看LD_LIBRARY_PATH方法

echo $LD_LIBRARY_PATH

查看nvidia驱动是否安装好

nvidia-smi
nvcc -v

在系统安装好驱动后,anaconda安装cudatoolkit是很方便的,需要配置好源,我使用的源如下(~/.condarc):

ssl_verify: true
channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
  - https://mirrors6.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
  - https://mirrors6.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
  - https://mirrors6.tuna.tsinghua.edu.cn/anaconda/cloud//pytorch/
show_channel_urls: true

安装cudatoolkit命令

conda install cudatoolkit=10.0

安装tensorflow-gpu命令

#1
conda install tensorflow-gpu=1.13.1
#2
pip install tensorflow-gpu=1.13.1

/home/kitty/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:526: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint8 = np.dtype([("qint8", np.int8, 1)])

出现上面警告是由于,tensorflow-gpu 1.13.1要求numpy版本不能太高,可以使用下面命令解决。

pip uninstall numpy
pip install numpy==1.16.4

测试GPU对安装的tensorflow是否可用

import tensorflow as tf
print(tf.test.is_gpu_available())

 

如果返回True,接下来tensorflow-gpu就可以正常使用了。

Ubuntu 18.04 CUDA10.1 Anaconda 安装tensorflow-gpu 1.13.1_第1张图片

安装好后python库列表

(py36) kitty@heal-PowerEdge-T630:~$ conda list
# packages in environment at /home/kitty/anaconda3/envs/py36:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                        main    https://mirrors6.tuna.tsinghua.edu.cn/anaconda/pkgs/main
blas                      1.1                    openblas    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
ca-certificates           2020.6.20            hecda079_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
certifi                   2020.6.20        py36h9f0ad1d_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
cudatoolkit               10.0.130                      0    https://mirrors6.tuna.tsinghua.edu.cn/anaconda/pkgs/main
future                    0.18.2                   pypi_0    pypi
keras-preprocessing       1.1.2                    pypi_0    pypi
ld_impl_linux-64          2.33.1               h53a641e_7    https://mirrors6.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libedit                   3.1.20191231         h14c3975_1    https://mirrors6.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libffi                    3.3                  he6710b0_2    https://mirrors6.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libgcc-ng                 9.1.0                hdf63c60_0    https://mirrors6.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libgfortran-ng            7.5.0               hdf63c60_14    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
libstdcxx-ng              9.1.0                hdf63c60_0    https://mirrors6.tuna.tsinghua.edu.cn/anaconda/pkgs/main
mock                      4.0.2                    pypi_0    pypi
ncurses                   6.2                  he6710b0_1    https://mirrors6.tuna.tsinghua.edu.cn/anaconda/pkgs/main
numpy                     1.16.4                   pypi_0    pypi
openblas                  0.3.3             h9ac9557_1001    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
openssl                   1.1.1g               h516909a_1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
pip                       20.2.1                   py36_0    https://mirrors6.tuna.tsinghua.edu.cn/anaconda/pkgs/main
python                    3.6.10               h7579374_2    https://mirrors6.tuna.tsinghua.edu.cn/anaconda/pkgs/main
python_abi                3.6                     1_cp36m    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
readline                  8.0                  h7b6447c_0    https://mirrors6.tuna.tsinghua.edu.cn/anaconda/pkgs/main
setuptools                49.2.1                   pypi_0    pypi
sqlite                    3.32.3               h62c20be_0    https://mirrors6.tuna.tsinghua.edu.cn/anaconda/pkgs/main
tensorflow-gpu            1.13.1                   pypi_0    pypi
tk                        8.6.10               hbc83047_0    https://mirrors6.tuna.tsinghua.edu.cn/anaconda/pkgs/main
wheel                     0.34.2                   pypi_0    pypi
xz                        5.2.5                h7b6447c_0    https://mirrors6.tuna.tsinghua.edu.cn/anaconda/pkgs/main
zlib                      1.2.11               h7b6447c_3    https://mirrors6.tuna.tsinghua.edu.cn/anaconda/pkgs/main

 

参考文献:

1.FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.解决办法

2.官网经过测试的构建配置

3.非ROOT用户安装CUDA和CUDNN

4.如何查看tensorflow-gpu是否可用

你可能感兴趣的:(tensorflow,深度学习)