创建虚拟环境:
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