记录tensorflow cpu版本安装

已有:anaconda环境

  • 创建虚拟环境

    conda create -n tf_cpu python=3.9.0

  • 进入虚拟环境

    activate tf_cpu

可以选择设置下载源

# 查看当前下载源
conda config --show-sources
# 添加下载源
# 清华镜像源
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/main/
# 中科大镜像源
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/
# 添加下载源后,设置搜索时显示通道地址
conda config --set show_channel_urls yes
# 删除下载源
#conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
  • 安装tensorflow

    pip install tensorflow-cpu

有点久的,慢慢等。

安装成功后,看看

(tf_cpu) C:\Windows\System32>python
Python 3.9.0 (default, Nov 15 2020, 08:30:55) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
2024-03-05 14:57:59.295381: I tensorflow/core/util/port.cc:113] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
WARNING:tensorflow:From D:\Software\Installation_path\Python_about\Anaconda3\envs\tf_cpu\lib\site-packages\keras\src\losses.py:2976: The name tf.losses.sparse_softmax_cross_entropy is deprecated. Please use tf.compat.v1.losses.sparse_softmax_cross_entropy instead.

>>> import tensorflow
>>> print(tensorflow.__version__)
2.15.0
>>> quit()

有个提示,但是无碍。

后面试了一下,项目导包也可以成功用了。

import tensorflow as tf
from tensorflow import keras
.........
#这不是完整的代码哦
base_model = tf.keras.applications.efficientnet.EfficientNetB3(include_top= False, weights= "imagenet", input_shape= img_shape, pooling= 'max')

tf.keras.applications.efficientnet.EfficientNetB3为了这句能正常跑,装了很多遍。

之前一直是jupter文件一句一句运行中间有问题,不知道为啥

后面直接一个python文件运行是可以的,所以之前的版本可能也是可以的。

相关推荐
坚毅不拔的柠檬柠檬2 分钟前
2025:人工智能重构人类文明的新纪元
人工智能·重构
jixunwulian8 分钟前
DeepSeek赋能AI边缘计算网关,开启智能新时代!
人工智能·边缘计算
Archie_IT16 分钟前
DeepSeek R1/V3满血版——在线体验与API调用
人工智能·深度学习·ai·自然语言处理
失败尽常态52322 分钟前
用Python实现Excel数据同步到飞书文档
python·excel·飞书
2501_9044477424 分钟前
OPPO发布新型折叠屏手机 起售价8999
python·智能手机·django·virtualenv·pygame
青龙小码农24 分钟前
yum报错:bash: /usr/bin/yum: /usr/bin/python: 坏的解释器:没有那个文件或目录
开发语言·python·bash·liunx
大数据追光猿30 分钟前
Python应用算法之贪心算法理解和实践
大数据·开发语言·人工智能·python·深度学习·算法·贪心算法
Leuanghing1 小时前
【Leetcode】11. 盛最多水的容器
python·算法·leetcode
灵感素材坊1 小时前
解锁音乐创作新技能:AI音乐网站的正确使用方式
人工智能·经验分享·音视频
xinxiyinhe2 小时前
如何设置Cursor中.cursorrules文件
人工智能·python