win10 anaconda cuda11.1 安装 tensorlfow-gpu 环境

注:之前写的那篇文章虽然安装成功了,但用不了gpu,今天从新弄一下,让它支持gpu

win10 anaconda 安装 tensorflow-gpu 及 jupyter notebook - Tiac - 博客园 (cnblogs.com)

 

本文链接:win10 anaconda cuda11.1 安装 tensorlfow-gpu 环境 - Tiac - 博客园 (cnblogs.com)

 

前期准备:

在安装 tensorflow-gpu 之前,请确认你已经安装好了 cuda 工具包及 cudann 补丁

CUDA:https://developer.nvidia.com/cuda-downloads

CUDANN:https://developer.nvidia.com/rdp/cudnn-download

注:需要注册一个 英伟达的 开发者账号


 

 

一、安装 anaconda

https://www.anaconda.com/products/individual

注1:选择适合自己的版本下载安装即可

注2:为了不必要的麻烦,建议先卸载系统已安装的python,然后使用anaconda默认环境的python做为系统默认的python 

  

 

二、安装 tensorflow-gpu

安装好 anaconda 后,win+q 搜索 ana ,选择打开 Anaconda Navigator

 

三、修改 anaconda 源

打开 C盘 > 用户 > {用户名},例如:C:\Users\Tiac

创建或修改 .condarc 文件并保存,内容参考 https://mirror.tuna.tsinghua.edu.cn/help/anaconda/

channels:
  - defaults
show_channel_urls: true
default_channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
  conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

 

四、创建 tensorflow-gpu 环境,并安装 tensorflow-gpu

参考链接:TensorFlow — Anaconda documentation

官方教程里有几种方法来安装 tensorflow-gpu,我试了,只有安装 nightly 版本的才比较正常(支持gpu)

conda create -n tf-n-gpu python
conda activate tf-n-gpu
pip install tf-nightly-gpu

 

五、验证环境是否正常

python
import tensorflow as tf
tf.__version__
tf.config.experimental.list_physical_devices('GPU')

 

注:如图所示,tensorflow已安装正常,可以识别到电脑的gpu

 

六、安装 jupyterlab

参考 jupyter 官方文档,用 conda 命令安装 jupyterlab

 https://jupyter.org/install.html

conda install -c conda-forge jupyterlab

 

 七、运行 jupyter-lab 及测试

 

 

 

 

本文链接:win10 anaconda cuda11.1 安装 tensorlfow-gpu 环境 - Tiac - 博客园 (cnblogs.com)


 完。 

 

posted @ 2021-05-11 22:32  Tiac  阅读(2143)  评论(0编辑  收藏  举报