ubuntu 18.04安装tensorflow (CPU)

在已经安装anaconda环境及pip之后。

  1. 添加并设置pip配置文件:
mkdir ~/.pip
vim ~/.pip/pip.conf

pip.conf文件内容:

[global]
index-url=http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com
  1. 安装tensorflow
# pip install tensorflow
# pip uninstall tensorflow
pip install tensorflow-cpu
  1. 测试tensorflow
#!/usr/local/bin/python3
import tensorflow as tf

hello = tf.constant('Hello, tf!')
sess = tf.Session()
print (sess.run(hello))

a = tf.constant(10)
b = tf.constant(32)
print (sess.run(a+b))

matrix1 = tf.constant([[3., 3.]])
matrix2 = tf.constant([[2.],[2.]])
product = tf.matmul(matrix1, matrix2)
result = (sess.run(product))
print (result)

sess.close()

参考:

posted @   山岚2013  阅读(152)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
点击右上角即可分享
微信分享提示