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

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.xdnf.cn/news/3358.html

相关文章:

  • 内网穿透系列二:使用cpolar公开一个本地Web站点到公网
  • 补题:K - Magic Tree (Gym - 105231K)
  • Java 期中考试试题考点剖析
  • jupyter notebook汉化教程
  • 打包 Python 项目为 Windows 可执行文件:高效部署指南
  • 题解:CF1398D Colored Rectangles
  • 【一】 基本概念与应用领域【数字图像处理】
  • Python基本语法(控制语句)
  • Spring IoC容器的设计与实现
  • ERP系统(技术面)知识积累
  • Transformer架构的解耦重组现象
  • SpringTas定时任务使用详解
  • GPU虚拟化实现(七)
  • MySQL基础关键_003_DQL(二)
  • 动态规划简单题
  • 【验证技能】验证质量活动及其执行注意事项
  • 权限提升—Linux提权内核溢出漏洞辅助项目
  • 【QNX+Android虚拟化方案】138 - USB 底层传输原理
  • 实验五 完整性
  • 初学者如何学习AI问答应用开发范式
  • PostgreSQL数据类型
  • 使用Python和Pandas实现的Amazon Redshift权限检查与SQL生成用于IT审计
  • 【DeepMLF】具有可学习标记的多模态语言模型,用于情感分析中的深度融合
  • EBO的使用
  • 基于python的人工智能应用简述
  • Spring 提供了多种依赖注入的方式
  • C#泛型集合深度解析(九):掌握System.Collections.Generic的核心精髓
  • 电池预测 | 第27讲 基于CNN卷积神经网络的锂电池剩余寿命预测
  • x86架构详解:定义、应用及特点
  • C++/SDL 进阶游戏开发 —— 双人塔防(代号:村庄保卫战 18)