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

相关推荐
飞Link6 分钟前
【网络与 AI 工程的交叉】多模态模型的数据传输特点:视频、音频、文本混合通道
网络·人工智能·音视频
老蒋新思维18 分钟前
创客匠人峰会实录:知识变现的场景化革命 —— 创始人 IP 如何在垂直领域建立变现壁垒
网络·人工智能·tcp/ip·重构·知识付费·创始人ip·创客匠人
老蒋新思维25 分钟前
创客匠人峰会深度解析:智能体驱动知识变现的数字资产化路径 —— 创始人 IP 的长期增长密码
人工智能·网络协议·tcp/ip·重构·知识付费·创始人ip·创客匠人
测试199831 分钟前
功能测试、自动化测试、性能测试的区别
自动化测试·python·功能测试·测试工具·职场和发展·性能测试·安全性测试
为爱停留39 分钟前
Spring AI实现RAG(检索增强生成)详解与实践
人工智能·深度学习·spring
像风没有归宿a1 小时前
2025年人工智能十大技术突破:从AGI到多模态大模型
人工智能
Data_agent1 小时前
1688获得1688店铺所有商品API,python请求示例
java·开发语言·python
深鱼~1 小时前
十分钟在 openEuler 上搭建本地 AI 服务:LocalAI 快速部署教程
人工智能
一晌小贪欢1 小时前
【Python办公】-图片批量添加文字水印(附代码)
开发语言·python·图片水印·python水印·python添加水印·图片添加水印