Ananconda虚拟环境下安装tensorflow、spyder

本文介绍了如何在Ubuntu系统中使用Anaconda创建虚拟环境,并在该环境中安装TensorFlow-GPU和Spyder。通过添加清华源加速下载,详细步骤包括创建环境、安装依赖、验证TensorFlow安装及在环境中安装Spyder。
摘要由CSDN通过智能技术生成

创建虚拟环境:
conda create -n tf python==3.8.3

进入:
source activate tf

进入虚拟化环境之后,换源、安装tensorflow的gpu版(不然太慢了):
(加清华源)
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes

更新apt(好像不需要这一步):
sudo apt-get update

conda install tensorflow-gpu

试试是否安装成功:
python
import tensorflow as tf

安装spyder
conda install spyder

检查spyder里面能否顺利运行tensorflow:
import tensorflow as tf
tf.compat.v1.disable_eager_execution() #保证sess.run()能够正常运行
hello = tf.constant(‘hello,tensorflow’)
sess= tf.compat.v1.Session() #版本2.0的函数
print(sess.run(hello))

参考:
用的是虚拟化环境,每次需要先进入conda的虚拟环境再进入spyder࿰

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值