记录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文件运行是可以的,所以之前的版本可能也是可以的。

相关推荐
Leinwin18 分钟前
双城奔赴,智领未来:领驭科技亮相2026微软AI Tour上海·香港站
人工智能·科技·microsoft
时空系21 分钟前
第10篇:继承扩展——面向对象编程进阶 python中文编程
开发语言·python·ai编程
洋子22 分钟前
Yank Note 系列 13 - 让 AI Agent 进入笔记工作流
前端·人工智能
侠客工坊32 分钟前
移动端 RPA 的架构重构:基于侠客工坊多模态视觉大模型的自动化调度系统压测复盘
人工智能·智能手机·重构·架构·rpa·数字员工·侠客工坊
胖墩会武术36 分钟前
Obsidian 与 Obsidian Skills 小白入门
人工智能·ai·obsidian·obsidian skills
河北小博博36 分钟前
李宏毅Harness Engineering课程逐字稿整理:有时候模型不是不够聪明,只是没有好的Harness
人工智能
Elastic 中国社区官方博客36 分钟前
Elastic-caveman : 在不损失 Elastic 最佳效果的情况下,将 AI 响应 tokens 减少64%
大数据·运维·数据库·人工智能·elasticsearch·搜索引擎·全文检索
云天AI实战派1 小时前
Agentic AI 全流程实战:用 OpenAI on AWS 搭一个餐饮补货智能体,从 API 调用到容器化上线
人工智能·云计算·aws
万岳科技程序员小金1 小时前
2026智慧药店系统源码趋势:药店APP+小程序开发新方向
人工智能·电子处方小程序·药店软件开发·药店系统源码·药店app开发·药店平台搭建·药店小程序
xingyuzhisuan1 小时前
稳定性考验:连续跑7天,哪家云主机不重启、不掉线?
服务器·人工智能·gpu算力