使用conda安装tensorflow已经成为许多机器学习科学家的呼吁,那我们今天就来看看如何shiy使用conda进行tensorflow和pytorch的快速安装吧~
# 添加conda源
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 --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
# 查看是否添加成功
conda config --show-sources
# 更新conda
conda update conda
# 安装tensorflow(1.12.0)
conda install tensorflow
# 安装pytorch
conda install pytorch-cpu torchvision-cpu -c pytorch
验证tensorflow安装成功:
import tensorflow as tf
tf.enable_eager_execution()
print(tf.reduce_sum(tf.random_normal([1000, 1000])))
验证pytorch安装成功:
import torch as t
t.__version__
如果都没有问题,那就恭喜你已经安装成功喽~~~