intel芯片 macbookpro 利用conda 安装tensorflow

// 终端输入
# Conda 创建虚拟环境 python版本3.8

conda create -n py38_tf python=3.8

# 激活进入虚拟环境

conda activate py38_tf

# pip安装tensorflow

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple/ tensorflow==2.6

至此就安装好了

之前遇到一些的问题

Q1.使用配置文件直接配置带有tensorflow的虚拟环境

// 在 .yaml文件所在目录下的终端中输入
conda env create -f tensorflow.yaml

但是出现报错

Solving environment:failed
ResolvePackage NotFound:

科学上网查到的解释:需要科学上网

(总结:所需要的包所在库因为 Conda版本问题,一些旧的包在新库下找不到)

原文

Conda v4.7 dropped a branch of the Anaconda Cloud repository called the free channel for the sake of improving solving performance. Unfortunately, this includes many older packages that never got ported to the repository branches that were retained. The requirements failing here are affected by this.

2种解决办法

Option 1: Permanent Setting
If you expect to frequently need older packages, then you can globally set the option and then proceed with installing:

conda config --set restore_free_channel true
conda env create -f virtual_platform_mac.yml

Option 2: Temporary Setting
As with all Conda configuration options, you can also use the corresponding environment variable to temporarily restore access just for the command:

Unix/Linux
CONDA_RESTORE_FREE_CHANNEL=1 conda env create -f virtual_platform_mac.yml
Windows
SET CONDA_RESTORE_FREE_CHANNEL=1
conda env create -f virtual_platform_mac.yaml

(Yes, I realize the cognitive dissonance of a …_mac.yaml, but Windows users need help too.)

Q2.conda 源问题

下载好Conda后没有设置国内源,下载缓慢
解决如下

# 添加清华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/pkgs/r
# 添加清华的pytorch镜像(可能会用到,可选)
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch
# 设置搜索时显示通道地址
conda config --set show_channel_urls yes

# 恢复默认源地址
conda config --remove-key channels
# 查看conda的config设置
conda config --show
# 查看当前conda的channel
conda config --show channels

Q3.安装 tensorflow版本问题

一开始如下安装:

pip install tensorflow==2.4.1

出现报错

ERROR: Could not find a version that satisfies the requirement tensorflow==2.4.1 (from versions: 2.5.0rc0, 2.5.0rc1, 2.5.0rc2, 2.5.0rc3, 2.5.0, 2.5.1, 2.5.2, 2.6.0rc0, 2.6.0rc1, 2.6.0rc2, 2.6.0, 2.6.1, 2.6.2, 2.7.0rc0, 2.7.0rc1, 2.7.0, 2.8.0rc0)
ERROR: No matching distribution found for tensorflow==2.4.1

改为

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple/ tensorflow==2.6

OK

配置好虚拟环境后,在Pycharm中新建项目,选择Conda环境–已有环境下找到配置好的tensorflow虚拟环境解释器位置即可

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值