centos7 安装 tensorflow-gpu 时遇到的问题汇总

本贴最后更新于 1586 天前,其中的信息可能已经时过境迁

th1.jpeg

1、TypeError: new() got an unexpected keyword argument 'serialized_options'

更新 protobuf
pip install -U protobuf

2、AttributeError: module 'tensorflow' has no attribute 'gfile'

tensorflow 包版本问题,版本要求 1.15 >= tensorflow >=1.10,更新 tensorflow 版本
pip install -U tensorflow==1.10 -i https://mirrors.aliyun.com/pypi/simple

3、ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory

CUDA 版本要求 9.0,下载对应版本安装
CUDA 下载地址:https://developer.nvidia.com/cuda-toolkit-archive
同时 cuDNN 也需要下载和 CUDA 对应的版本,将解压后的文件拷贝到 cuda 的安装目录(默认/usr/local/cuda-9.0)的对应目录下即可;
cuDNN 下载地址:https://developer.nvidia.com/rdp/cudnn-archive

tensorflow-gpu 运行环境安装检测程序

# -*- coding:utf-8 -*-
import tensorflow as tf

with tf.device('/cpu:0'):
    a = tf.constant ([1.0, 2.0, 3.0], shape=[3], name='a')
    b = tf.constant ([1.0, 2.0, 3.0], shape=[3], name='b')
with tf.device('/gpu:1'):
    c = a + b

sess = tf.Session(config=tf.ConfigProto (allow_soft_placement=True, log_device_placement=True))
# sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
sess.run(tf.global_variables_initializer())
print (sess.run(c))
  • TensorFlow

    TensorFlow 是一个采用数据流图(data flow graphs),用于数值计算的开源软件库。节点(Nodes)在图中表示数学操作,图中的线(edges)则表示在节点间相互联系的多维数据数组,即张量(tensor)。

    20 引用 • 19 回帖

相关帖子

欢迎来到这里!

我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。

注册 关于
请输入回帖内容 ...