win7安装tensorflow-gpu版(Anaconda)

本文档详细记录了在Windows 7系统上安装TensorFlow-GPU版的过程,包括所需的前提条件如CUDA Toolkit 8.0、cuDNN v5.1和兼容的GPU,以及解决Visual C++版本问题和创建Python 3.5环境进行安装的步骤。通过遵循这些步骤,成功安装并测试运行了TensorFlow-GPU版。
部署运行你感兴趣的模型镜像

参考文章:http://blog.youkuaiyun.com/sb19931201/article/details/53648615


自己的台式机装了影驰1050ti大将显卡,平时也不怎么玩游戏,干脆把TensorFlow-GPU版给装上试试。

本来想装docker版本,http://blog.youkuaiyun.com/ixuhangyi/article/details/52291716,但是据说docker对GPU的支持有限,且对本地开发环境的支持也不够友好,因此直接用pip安装的方式

官方指导:https://www.tensorflow.org/install/install_windows

最重要的就是满足下面的先决条件:注意版本都要对应,cuDNN v6.0亲测不行,必须要v5.1,此处安装过程请参考本文开头参考文章中win10的安装

Requirements to run TensorFlow with GPU support

If you are installing TensorFlow with GPU support using one of the mechanisms described in this guide, then the following NVIDIA software must be installed on your system:

  • CUDA® Toolkit 8.0. For details, see NVIDIA's documentation Ensure that you append the relevant Cuda pathnames to the %PATH% environment variable as described in the NVIDIA documentation.
  • The NVIDIA drivers associated with CUDA Toolkit 8.0.
  • cuDNN v5.1. For details, see NVIDIA's documentation. Note that cuDNN is typically installed in a different location from the other CUDA DLLs. Ensure that you add the directory where you installed the cuDNN DLL to your %PATH%environment variable.
  • GPU card with CUDA Compute Capability 3.0 or higher. See NVIDIA documentation for a list of supported GPU cards.

If you have an earlier version of the preceding packages, please upgrade to the specified versions.


遇到的坑:之前安装了visual c++2017的库,但是TensorFlow需要visual c++2015,卸载掉(x86 x64的visual c++2017都要卸载),重新安装2015,都弄完了最好重启下电脑


准备好前提条件后:打开命令行:创建一个Python3.5的环境tensor_flow ,因为TensorFlow只支持Python3.5

conda create -n tensor_flow python=3.5

激活环境:activate tensor_flow

pip安装TensorFlow:pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-1.1.0-cp35-cp35m-win_amd64.whl 

安装完成,进入Python交互命令行,运行测试样例,运行成功

         
    

您可能感兴趣的与本文相关的镜像

PyTorch 2.5

PyTorch 2.5

PyTorch
Cuda

PyTorch 是一个开源的 Python 机器学习库,基于 Torch 库,底层由 C++ 实现,应用于人工智能领域,如计算机视觉和自然语言处理

### 在 Windows 11 上安装 TensorFlow GPU 支持 #### 本兼容性注意事项 对于希望在 Windows 11 上使用带有 GPU 加速功能的 TensorFlow 用户来说,需要注意的是自 2.10 本之后官方已停止对原生 Windows 平台下的 GPU 配置的支持[^1]。因此,在此操作系统环境中部署 TensorFlowGPU 功能通常建议通过 WSL2 (Windows Subsystem for Linux version 2) 来实现。 #### 使用 WSL2 进行安装 为了能够在 Windows 11 中利用 GPU 资源运行 TensorFlow,推荐的方法是在 WSL2 下创建 Ubuntu 或其他受支持的 Linux 发行实例,并在此基础上完成必要的软件栈搭建工作。具体操作流程涉及以下几个方面: - 打开 PowerShell 作为管理员执行命令 `wsl --install` 自动下载并设置默认的 Linux 发行- 对于某些特定情况可能还需要调整 `/etc/wsl.conf` 文件中的选项来优化性能表现。 - **安装 NVIDIA CUDA 工具包与驱动程序** - 访问[NVIDIA 官方网站](https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=2004&target_type=deblocal),按照指引获取适用于目标系统的二进制文件。 - 注意选择与所使用的显卡型号相匹配的本号。 - **配置 cuDNN 库** - 获取来自同一制造商提供的深度神经网络库——cuDNN,它能够显著提升模型训练效率。 - 将解压后的头文件夹复制到 CUDA 安装路径下相应位置即可生效。 - **准备 Python 开发环境** - 推荐采用 Miniconda 或 Anaconda 创建独立的工作区以隔离不同项目间的依赖关系冲突风险。 - 利用 pip 或者 conda 命令行工具快速拉取最新的稳定 TensorFlow 包含 GPU 支援的部分。 ```bash # 更新系统包索引 sudo apt update && sudo apt upgrade -y # 添加NVIDIA APT仓库密钥和源列表条目 distribution=$(. /etc/os-release;echo $UBUNTU_CODENAME) curl -fsSL https://developer.download.nvidia.com/compute/cuda/repos/$distribution/x86_64/7fa2af80.pub | gpg --dearmor -o /usr/share/keyrings/nvidia.gpg echo "deb [signed-by=/usr/share/keyrings/nvidia.gpg] https://developer.download.nvidia.com/compute/cuda/repos/$distribution/x86_64 /" | tee /etc/apt/sources.list.d/cuda.list # 安装CUDA Toolkit及其配套组件 sudo apt-get install cuda-drivers cuda-toolkit -y # 设置环境变量使当前shell会话立即可用新安装的内容 export PATH=/usr/local/cuda/bin:$PATH export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH # 关闭终端重新打开使之永久有效 ``` ```python # 创建新的Conda环境名为tf_gpu_env conda create -n tf_gpu_env python=3.9 # 激活该环境 conda activate tf_gpu_env # 安装TensorFlow GPU本及相关科学计算库 pip install tensorflow==2.12.0 numpy matplotlib jupyterlab ipython ``` 最后一步验证是否成功加载了 GPU 设备信息: ```python import tensorflow as tf print(tf.__version__) device_name = tf.test.gpu_device_name() if device_name != '/device:GPU:0': raise SystemError('GPU device not found') print(f'Found GPU at: {device_name}') ```
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值