WIN10+CUDA11.0+anaconda3+tensorflow-gpu2.4.0安装过程

今天换了台式机,安装tensorflow花了不少时间,记录下。

一 确认自己要安装哪些版本的软件

首先查看自己电脑显卡支持的CUDA版本,我的的支持11.1

桌面空白处,鼠标点右键,选择NVIDIA控制面板

打开NVIDIA控制面板,选择 帮助->系统信息->组件,可以看到CUDA版本

根据显卡支持的CUDA版本,选择对应的支持的tensorflow最高版本,点击下面地址就可以查看对应的版本,各个版本一定要选对且匹配,不然后面很折腾。因为tensorflow没有支持CUDA11.1的版本,为了兼容所以我选了CUDA11.0对应的一列配置。

在 Windows 环境中从源代码构建  |  TensorFlow

准备安装CUDA 11.0    cuDNN 8.0  python 3.8(anaconda3)   MS visual studio2019

tensorflow_gpu 2.4.0     Bazel 3.1.0

 二 下载CUDA11.0

官方地址 CUDA Toolkit 11.0 Download | NVIDIA Developer

 

安装CUDA

 自定义这里把Visual Studio Integration勾选去掉

 其他组件也去掉

三 cuDNN下载和安装

cuDNN下载地址:   cuDNN Archive | NVIDIA Developer

我下载的是文章前面列表推荐的cuDNN 8.0

 cuDNN不需要安装,解压后放入对应文件夹即可

cudnn-11.0-windows-x64-v8.0.2.39进行解压,如下

将上面文件copy到如下目录

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0

四 Visual Studio 2019依赖包安装

最新支持的 Visual C++ 可再发行程序包下载 | Microsoft Docs

 这个支持库建议安装,否则后面各种坑,支持库只有10多MB。安装后重启。

五 anaconda安装

因为我打算装python3.8, 对应的anaconda版本是anaconda2020.11 即 Anaconda3-2020.11-Windows-x86_64

anaconda下载地址   Index of /

 

安装完成后,打开conda prompt

添加国内镜像, 换源, 或者进入用户文件夹,修改 .condarc

添加国内镜像, 换源
https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
(base) C:\Users\mayn>conda -V
conda 4.9.2
(base) C:\Users\mayn>conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
(base) C:\Users\mayn>conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
(base) C:\Users\mayn>conda config --set show_channel_urls yes

 

Anacoda创建一个名字叫做tensorflow-gpu的python独立环境

Conda create –n tensorflow-gpu python=3.8

 创建完成提示了激活方法和删除方法,使用命令激活并进入创建好的空间

conda activate tensorflow-gpu

六 安装tensorflow

现在keras已经集成到tensorflow中,所以直接安装即可

更新pip:   python –m pip install –-upgrade pip

执行命令 :pip install tensorflow-gpu==2.4.0

python –m pip install –-upgrade pip
pip install tensorflow-gpu==2.4.0

 

七 pycharm搭建anaconda和tensorflow环境

Pycharm设置解释器,选择conda环境,tenorflow-gpu 

 测试GPU是否ok

# import tensorflow.compat.v1 as tf
import tensorflow as tf
from tensorflow.python.client import device_lib

import os
os.environ['TF_CPP_MIN_LOG_LEVEL']='2'

local_device = device_lib.list_local_devices()
print(local_device)
for item in local_device:
    print(item)

print(tf.config.list_physical_devices('GPU'))

 至此搭建完成。

  • 2
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
自编译tensorflow: 1.python3.5,tensorflow1.12; 2.支持cuda10.0,cudnn7.3.1,TensorRT-5.0.2.6-cuda10.0-cudnn7.3; 3.支持mkl,无MPI; 软硬件硬件环境:Ubuntu16.04,GeForce GTX 1080 配置信息: hp@dla:~/work/ts_compile/tensorflow$ ./configure WARNING: --batch mode is deprecated. Please instead explicitly shut down your Bazel server using the command "bazel shutdown". You have bazel 0.19.1 installed. Please specify the location of python. [Default is /usr/bin/python]: /usr/bin/python3 Found possible Python library paths: /usr/local/lib/python3.5/dist-packages /usr/lib/python3/dist-packages Please input the desired Python library path to use. Default is [/usr/local/lib/python3.5/dist-packages] Do you wish to build TensorFlow with XLA JIT support? [Y/n]: XLA JIT support will be enabled for TensorFlow. Do you wish to build TensorFlow with OpenCL SYCL support? [y/N]: No OpenCL SYCL support will be enabled for TensorFlow. Do you wish to build TensorFlow with ROCm support? [y/N]: No ROCm support will be enabled for TensorFlow. Do you wish to build TensorFlow with CUDA support? [y/N]: y CUDA support will be enabled for TensorFlow. Please specify the CUDA SDK version you want to use. [Leave empty to default to CUDA 10.0]: Please specify the location where CUDA 10.0 toolkit is installed. Refer to README.md for more details. [Default is /usr/local/cuda]: /usr/local/cuda-10.0 Please specify the cuDNN version you want to use. [Leave empty to default to cuDNN 7]: 7.3.1 Please specify the location where cuDNN 7 library is installed. Refer to README.md for more details. [Default is /usr/local/cuda-10.0]: Do you wish to build TensorFlow with TensorRT support? [y/N]: y TensorRT support will be enabled for TensorFlow. Please specify the location where TensorRT is installed. [Default is /usr/lib/x86_64-linux-gnu]:/home/hp/bin/TensorRT-5.0.2.6-cuda10.0-cudnn7.3/targets/x86_64-linux-gnu Please specify the locally installed NCCL version you want to use. [Default is to use https://github.com/nvidia/nccl]: Please specify a list of comma-separated Cuda compute capabilities you want to build with. You can find the compute capability of your device at: https://developer.nvidia.com/cuda-gpus. Please note that each additional compute capability significantly increases your build time and binary size. [Default is: 6.1,6.1,6.1]: Do you want to use clang as CUDA compiler? [y/N]: nvcc will be used as CUDA compiler. Please specify which gcc should be used by nvcc as the host compiler. [Default is /usr/bin/gcc]: Do you wish to build TensorFlow with MPI support? [y/N]: No MPI support will be enabled for TensorFlow. Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is -march=native -Wno-sign-compare]: Would you like to interactively configure ./WORKSPACE for Android builds? [y/N]: Not configuring the WORKSPACE for Android builds. Preconfigured Bazel build configs. You can use any of the below by adding "--config=" to your build command. See .bazelrc for more details. --config=mkl # Build with MKL support. --config=monolithic # Config for mostly static monolithic build. --config=gdr # Build with GDR support. --config=verbs # Build with libverbs support. --config=ngraph # Build with Intel nGraph support. --config=dynamic_kernels # (Experimental) Build kernels into separate shared objects. Preconfigured Bazel build configs to DISABLE default on features: --config=noaws # Disable AWS S3 filesystem support. --config=nogcp # Disable GCP support. --config=nohdfs # Disable HDFS support. --config=noignite # Disable Apacha Ignite support. --config=nokafka # Disable Apache Kafka support. --config=nonccl # Disable NVIDIA NCCL support. Configuration finished 编译: hp@dla:~/work/ts_compile/tensorflow$ bazel build --config=opt --config=mkl --verbose_failures //tensorflow/tools/pip_package:build_pip_package 卸载已有tensorflow: hp@dla:~/temp$ sudo pip3 uninstall tensorflow 安装自己编译的成果: hp@dla:~/temp$ sudo pip3 install tensorflow-1.12.0-cp35-cp35m-linux_x86_64.whl
使用Anaconda3和PyCharm来配置TensorFlow-GPU 2.4.0深度学习环境是一个相对简单的过程,我将分享我的经验。 首先,你需要确保已经在计算机上安装Anaconda3和PyCharm。然后,你可以按照以下步骤进行配置: 1. 打开Anaconda Navigator,并创建一个新的虚拟环境。你可以选择Python 3.7版本,并命名环境为"tensorflow-gpu"。 2. 激活新环境后,在终端或命令提示符下输入以下命令来安装TensorFlow-GPU 2.4.0: ``` conda install tensorflow-gpu=2.4.0 ``` 3. 安装完成后,你可以通过以下命令验证TensorFlow-GPU是否正确安装: ``` python -c "import tensorflow as tf; print(tf.__version__)" ``` 如果输出显示为2.4.0,则说明TensorFlow-GPU已经成功安装。 4. 接下来,在PyCharm中打开一个新的项目。在项目设置中,选择已创建的虚拟环境"tensorflow-gpu"作为项目的Python解释器。 5. 在PyCharm的终端中,使用以下命令来安装GPU版本的TensorFlow依赖项: ``` pip install tensorflow-gpu==2.4.0 ``` 6. 安装完成后,你可以编写和运行使用TensorFlow-GPU的代码了。 在配置过程中,可能会遇到一些问题。例如,TensorFlow-GPU要求计算机上安装了适当的显卡驱动程序,并且CUDA和cuDNN版本与TensorFlow-GPU的要求相匹配。此外,如果你在安装过程中遇到任何问题,可以尝试升级或降级Anaconda、PyCharm和TensorFlow-GPU版本,以找到兼容的组合。 总之,通过Anaconda3和PyCharm配置TensorFlow-GPU 2.4.0深度学习环境是一项相对简单的任务。如果按照上述步骤操作,你应该能够成功地设置和使用TensorFlow-GPU来进行深度学习任务。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值