当前位置: 首页 > news >正文

python310 安装 tensorflow-gpu2.10

python310 安装 tensorflow-gpu2.10

工具 miniconda

环境准备

  1. 升级依赖库

    conda update --all
    
  2. 创建目录

    mkdir gpu-tf
    
  3. 进入目录

    cd gpu-tf
    
  4. 创建虚拟环境

    conda create -p tf210-310 python==3.10.16
    
  5. 激活虚拟环境

    conda activate D:\gpu-tf\tf210-310
    
  6. 重新安装pip

    python -m pip uninstall pip
    python -m ensurepip --upgrade
    
  7. 升级 setuptools wheel

    python -m pip install --upgrade pip setuptools wheel
    

安装cudacudnn

conda install cudatoolkit==11.3.1 cudnn==8.2.1

安装 numpy

解决版本兼容

pip install numpy==1.26.4

安装 tensorflow-gpu

pip install tensorflow-gpu==2.10.1

tensorflow-gpu

测试

  1. 控制台输入 python 进入 python 环境后输入以下内容:

    import tensorflow as tf# 打印TensorFlow版本信息
    print("TensorFlow version:", tf.__version__)# 检查GPU是否可用
    print("GPU is available:", end='\t' )
    print(tf.config.list_physical_devices('GPU'))
  2. 编写 python 文件,代码如下:

    import tensorflow as tf# 打印TensorFlow版本信息
    print("TensorFlow version:", tf.__version__)# 检查GPU是否可用
    if tf.config.list_physical_devices('GPU'):print("GPU is available")
    else:print("GPU is not available")# 使用tf.function装饰器自动将操作分配到GPU(如果可用)
    @tf.function
    def test_gpu():a = tf.constant([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]])b = tf.constant([[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]])c = tf.matmul(a, b)return c# 调用函数并打印结果
    result = test_gpu()
    print(result)
  3. 运行刚刚编写的 python 文件,输入内容如下: python310 安装 tensorflow-gpu2.10

http://www.dtcms.com/a/167412.html

相关文章:

  • 【c语言】字符函数和字符串函数
  • PostgreSQL数据表操作SQL
  • python3GUI--视频监控管理平台 By:PyQt5(详细讲解)
  • Python-pandas-json格式的数据操作(读取数据/写入数据)
  • 天车定位技术方案(基于无线脉冲技术)
  • C++11新特性_范围-based for 循环
  • 长成一个西瓜
  • 【业务领域】电脑网卡是主板还是cpu(主板的网卡是什么意思)
  • Sigmoid函数导数推导详解
  • 拆解 browser-use 项目——深入理解 Agent 层
  • CUDA从入门到放弃
  • 小结:ipsec-ike
  • 使用 MCP(模型上下文协议)和 Claude 在 Node.js 中构建聊天应用程序
  • Learning vtkjs之DepthTest
  • 21.2Linux中的LCD驱动实验(驱动)_csdn
  • [操作系统] 线程互斥
  • 大模型 Function Call
  • Unity SpriteEditor(精灵图片编辑器)
  • 24.Linux中RTC的驱动实验_csdn
  • 1.67g 雨晨 22635.5305 Windows 11 企业版 23H2 极速增强版
  • 边缘计算革命:大模型轻量化部署全栈实战指南
  • 机器人--底盘
  • 链表系列一>合并 k 个升序链表
  • Sublime Text4 4192 安装和一键激活
  • 基于Redis实现-附近商铺查询
  • 在项目中如何对Map List等对象序列化及反序列化
  • 第二章 OpenCV篇-图像阈值的综合操作-Python
  • 【瑞萨RA4L1-SENSOR套件测评】LCD 实时显示 ADC 水位高度
  • vue中$set原理
  • AIO-1126-JD4蓝牙通讯(BLE)