以前安装先安装驱动,在安装cuda 在配置cudnn,总是在cudnn这里出错,
出现问题:安装成功后,出现重启机器无限输入密码问题,应该是显卡驱动被cuda 覆盖了,重新安装即可
又是配置环境变量,都不好使,现在换了conda 一键安装好用,太好用了。
首先安装anaconda,简单,不说了
安装NVIDIA驱动 之后使用 $ nvidia-smi进行验证:
之后添加conda 国内镜像源 为了加快安装速度
conda源更改:
conda源国内只有清华有,
修改源只需输入如下两条命令:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
---------------------
不用安装cuda 和cudnn了,conda直接可以给你安装好了
找到合适的TensorFlow-GPU版本以及对应的cuda、cudnn版本
使用命令 conda search tensorflow-gpu 查找:
首先看看我的Python版本,是3.6,于是找到了tensorflow-gpu 1.2.1 版本,安装这个版本
安装 一步到位 有了中国镜像源很快,不然等到死也安装不了
zjw@zjw-System-Product-Name:~$ conda install tensorflow-gpu==1.2.1
安装完毕
检验tensorflow是否可以正常使用
import numpy
import tensorflow as tf
a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a')
b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b')
c = tf.matmul(a, b)
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
print(sess.run(c))
Pycharm可以正常使用,