解决win10下用conda安装PyTorch太慢的问题
此教程安装的是tensorflow2.3;
安装tensorflow-gpu==1.13.1或其他版本,与下述步骤相同,不同点:
conda install cudatoolkit=10.0.130
conda install cudnn=7.6
pip install tensorflow-gpu==1.13.1 -i https:…pypi.tuan.tsinghua.edu.cn/simple
- 进入
conda设置清华源【此为安装pytorch的国内镜像源】
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
conda config --set show_channel_urls yes
查看已添加的conda镜像源
conda config --show
- 使用conda创建虚拟环境
conda create -n name python=x.x (name为设置的环境变量名)
进入conda虚拟环境:conda activate name
安装cuda
conda install cudatoolkit=10.1
安装tensorflow-gpu==1.13.1版本时:
conda install cudatoolkit=10.0.130或10.0
安装cudnn
pip install tensorflow-gpu==2.3.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
Or
pip install tensorflow-gpu==2.3.0 -i https://pypi.douban.com/simple
安装tensorflow-gpu==1.13.1版本时:
pip install tensorflow-gpu==1.13.1 -i https:…pypi.tuan.tsinghua.edu.cn/simple
安装成功
测试验证tensorflow-gpu是否安装成功
Python
(tf23_py37) C:\Users\4102>python
Python 3.7.7 (default, May 6 2020, 11:45:54) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type “help”, “copyright”, “credits” or “license” for more information.
>>> import tensorflow as tf
2020-09-01 12:13:54.143035: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cudart64_101.dll
>>> tf.version
‘2.3.0’
>>>
至此,tensorflow-gpu安装成功。
注:安装其他第三方库:
pip install numpy(==2.3.0) -i https://pypi.tuna.tsinghua.edu.cn/simple
Or
pip install openslide(==1.1.0) -i https://pypi.douban.com/simple
卸载
参考:解决win10下用conda安装PyTorch太慢的问题https://www.it610.com/article/1278355336264171520.htm