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

相关推荐
嗷嗷哦润橘_几秒前
AI Agent学习:MetaGPT之我的工作
人工智能·学习·flask
PPIO派欧云3 分钟前
PPIO上线阿里Wan 2.6:制作电影级AI视频,对标Sora2
人工智能
火山kim16 分钟前
经典论文研读报告:DAGGER (Dataset Aggregation)
人工智能·深度学习·机器学习
祁思妙想17 分钟前
linux常用命令
开发语言·python
流水落花春去也27 分钟前
用yolov8 训练,最后形成训练好的文件。 并且能在后续项目使用
python
Coding茶水间28 分钟前
基于深度学习的水果检测系统演示与介绍(YOLOv12/v11/v8/v5模型+Pyqt5界面+训练代码+数据集)
图像处理·人工智能·深度学习·yolo·目标检测·机器学习·计算机视觉
Serendipity_Carl28 分钟前
数据可视化实战之链家
python·数据可视化·数据清洗
檐下翻书17330 分钟前
算法透明度审核:AI 决策的 “黑箱” 如何被打开?
人工智能
undsky_33 分钟前
【RuoYi-SpringBoot3-Pro】:接入 AI 对话能力
人工智能·spring boot·后端·ai·ruoyi
网易伏羲44 分钟前
网易伏羲受邀出席2025具身智能人形机器人年度盛会,并荣获“偃师·场景应用灵智奖
人工智能·群体智能·具身智能·游戏ai·网易伏羲·网易灵动·网易有灵智能体