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

安装 tensorflow-2.10.0 支持 gpu

1. 起因, 目的:

  • 重新安装 tensorflow gpu, 因为之前的项目都删掉了。遇到一点问题,记录一下。
  • 来回折腾,本质是 我的 python3.11 版本太高了。换成 python3.9 就行了。
  • 坚决不使用 AI 扩写。垃圾而恶心。

2. 先看效果

无。

3. 过程:

代码
import platform
import sys
import os
import subprocess
import shutildef check_os():os_type = platform.system()arch = platform.machine()print(f"操作系统: {os_type}")print(f"系统架构: {arch}")def check_python():print(f"Python 版本: {platform.python_version()}")print(f"Python 位数: {platform.architecture()[0]}")def check_cuda_toolkit():possible_paths = ["C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA","/usr/local/cuda",]found = Falsefor path in possible_paths:if os.path.exists(path):print(f"已检测到 CUDA Toolkit 安装路径: {path}")found = Truebreakif not found:print("未检测到 CUDA Toolkit 安装路径")def check_nvidia_smi():try:result = subprocess.run(["nvidia-smi"], capture_output=True, text=True)if result.returncode == 0:print("✅ 已检测到 NVIDIA GPU:")print(result.stdout.split("\n")[0])  # 打印首行信息else:print("⚠️ 未检测到 NVIDIA GPU 或未安装驱动")except FileNotFoundError:print("⚠️ 未安装 NVIDIA 驱动(nvidia-smi 命令不可用)")def main():print("=== 系统信息检测 ===")check_os()print()check_python()print()check_cuda_toolkit()print()check_nvidia_smi()print("====================")if __name__ == "__main__":main()"""
输出:=== 系统信息检测 ===
操作系统: Windows
系统架构: AMD64Python 版本: 3.11.1
Python 位数: 64bit已检测到 CUDA Toolkit 安装路径: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA✅ 已检测到 NVIDIA GPU:
Fri May 23 05:02:23 2025       
====================而且:(venv) C:\Users\Administrator\Code\python_nlp>nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver                  
Copyright (c) 2005-2022 NVIDIA Corporation             
Built on Tue_Mar__8_18:36:24_Pacific_Standard_Time_2022
Cuda compilation tools, release 11.6, V11.6.124        
Build cuda_11.6.r11.6/compiler.31057947_0              (venv) C:\Users\Administrator\Code\python_nlp>         (venv) C:\Users\Administrator\Code\python_nlp>nvidia-smi
Fri May 23 05:07:25 2025                                                                   
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 572.70                 Driver Version: 572.70         CUDA Version: 12.8     |
|-----------------------------------------+------------------------+----------------------+
| GPU  Name                  Driver-Model | Bus-Id          Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
|                                         |                        |               MIG M. |
|  GPU   GI   CI              PID   Type   Process name                        GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|    0   N/A  N/A            2300    C+G   ...ram Files\Tencent\QQNT\QQ.exe      N/A      |
|    0   N/A  N/A            8288    C+G   ...h_cw5n1h2txyewy\SearchApp.exe      N/A      |
|    0   N/A  N/A            9224    C+G   ...xyewy\ShellExperienceHost.exe      N/A      |
|    0   N/A  N/A           10644    C+G   C:\Windows\explorer.exe               N/A      |
|    0   N/A  N/A           11168    C+G   ...1.1.1\jbr\bin\jcef_helper.exe      N/A      |
|    0   N/A  N/A           12428    C+G   ...5n1h2txyewy\TextInputHost.exe      N/A      |
|    0   N/A  N/A           13452    C+G   ...Chrome\Application\chrome.exe      N/A      |
|    0   N/A  N/A           14156    C+G   ...acted\runtime\WeChatAppEx.exe      N/A      |
|    0   N/A  N/A           14396    C+G   ...Chrome\Application\chrome.exe      N/A      |
|    0   N/A  N/A           16664    C+G   ....0.3240.76\msedgewebview2.exe      N/A      |
+-----------------------------------------------------------------------------------------+(venv) C:\Users\Administrator\Code\python_nlp>
(venv) C:\Users\Administrator\Code\python_nlp>请根据我的系统信息,帮我配置 tensorflow gpu , 如何安装,请给出具体步骤。# 我的 python3.11, 版本太高了, 不行。换成 python3.9 可以的!
pip install tensorflow==2.10.0 -i https://pypi.org/simple"""

4. 结论 + todo

  • 繁琐是难免的。容易吗,不容易!

希望对大家有帮助。

相关文章:

  • debug一个cpu频率一直最低的问题
  • 的卢导表:简单易用的数据库同步工具
  • 科技化企业展厅需关注哪些前沿技术?互动设计如何提升用户体验?
  • CMake创建C++项目与npm创建nodejs项目异曲同工
  • MyBatis-Plus 中 QueryWrapper 的 Limit 实现
  • paddle 打包代码 ocr
  • 知道不知道
  • CSS 列表样式完全解析:从 ul/ol 基础到自定义样式
  • qt出现launching debugger,运行失败
  • 线性代数基础
  • day24Node-node的Web框架Express
  • Stable Diffusion底模对应的VAE推荐
  • 深度学习优化器相关问题
  • 一些Dify聊天系统组件流程图架构图
  • 单片机——实现交通信号灯管理
  • 学习STC51单片机13(芯片为STC89C52RC)
  • leetcode 61. Rotate List和86. Partition List
  • 搭建自己的语音对话系统:开源 S2S 流水线深度解析与实战
  • 实验-设计一个应用系统(计算机组成原理)
  • CentOS停止维护了,解决yum不能安装软件的问题
  • linux 网站开发/企业网站建设的步骤
  • wordpress建站镜像/提交网址给百度
  • 真么在网站里搜索/百度实时热搜榜
  • 邹城做网站/百度下载安装2019
  • 购物网站用那个软件做/百度指数分析大数据
  • 互联网网站开发有哪些职位/百度推广后台登陆首页