赞
踩
最近被tensorflow搞死,本来是不喜欢anaconda这种庞然大物,一锅炖的感觉,但是,为了更高效,专业的事交给专业的工具,毕竟人家已经存在这么久了,应该也是集成环境的扛把子。
【机器环境】
电脑 win10
anaconda3 5.3.1
下载地址:https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/?C=N&O=D
安装的时候勾了path和安装python3.7和vxcode,一切听它的,本来我的但是python3.6.8结果anaconda自带的3.7,还得我强迫症,去下载了3.6.8安装包重新安装一次,再重写uninsatll一次,再把文件夹删了,把配了anaconda3的C:\Users\shan-del目录下的site.py的USER_BASE和USER_SITE,
python -m site查看配置成功如下:
C:\Users\shan-dell>python -m site
sys.path = [
'C:\\Users\\shan-dell',
'E:\\anaconda3\\python37.zip',
'E:\\anaconda3\\DLLs',
'E:\\anaconda3\\lib',
'E:\\anaconda3',
'E:\\anaconda3\\lib\\site-packages',
'E:\\anaconda3\\lib\\site-packages\\win32',
'E:\\anaconda3\\lib\\site-packages\\win32\\lib',
'E:\\anaconda3\\lib\\site-packages\\Pythonwin',
]
USER_BASE: 'E:\\anaconda3\\Scripts' (exists)
USER_SITE: 'E:\x07naconda3\\Lib\\site-packages' (doesn't exist)
ENABLE_USER_SITE: True
GPU还是创建一个新环境比较好
1、查看当前环境conda env list
非常干净,只有一个环境
C:\Users\shan-dell>conda env list
#conda environments:
base * E:\anaconda3
2、创建tensorflow-gpu的安装环境:指定当前的python版本为3.7.0版本
#命令创建python版本为X.X、名字为your_env_name的虚拟环境。
conda create -n your_env_name python=X.X(2.7,3.6,3.7等)
输入如下
C:\Users\shan-dell>conda create -n tensorflow-gpu python=3.7.0 Solving environment: done ==> WARNING: A newer version of conda exists. <== current version: 4.5.11 latest version: 4.8.2 Please update conda by running $ conda update -n base -c defaults conda ##Package Plan ## environment location: E:\anaconda3\envs\tensorflow-gpu added / updated specs: - python=3.7.0 The following packages will be downloaded: package | build ---------------------------|----------------- vs2015_runtime-14.16.27012 | hf0eaf9b_1 2.4 MB pip-20.0.2 | py37_1 1.9 MB certifi-2019.11.28 | py37_0 157 KB wheel-0.34.2 | py37_0 67 KB setuptools-45.2.0 | py37_0 674 KB ------------------------------------------------------------ Total: 5.2 MB The following NEW packages will be INSTALLED: certifi: 2019.11.28-py37_0 pip: 20.0.2-py37_1 python: 3.7.0-hea74fb7_0 setuptools: 45.2.0-py37_0 vc: 14.1-h0510ff6_4 vs2015_runtime: 14.16.27012-hf0eaf9b_1 wheel: 0.34.2-py37_0 wincertstore: 0.2-py37_0
要装一堆的东西,慢慢等着出现done完成了
可使用conda env list查看当前环境是否创建成功,若成功则会显示tensorflow-gpu
3、激活虚拟环境
activate your_env_name
C:\Users\shan-dell>activate tensorflow-gpu
(tensorflow-gpu) C:\Users\shan-dell>
进到新的虚拟环境
4、conda安装tensorflow-gpu版本
安装前先配置一下清华镜像,之前查说2019年4月tuna不支持anaconda,后来2019年6月又说恢复,暂且抱着试一试的心态走下去
【conda设置清华镜像】
cmd输入
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes
查看C:\Users\shan-dell的.condarc文件显示
channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
- defaults show_channel_urls: true
在新建的tensorflow-gpu虚拟环境安装tensorflow-gpu版本
conda install tensorflow-gpu
(tensorflow-gpu) C:\Users\shan-dell>conda install tensorflow-gpu Solving environment: done ==> WARNING: A newer version of conda exists. <== current version: 4.5.11 latest version: 4.8.2 Please update conda by running $ conda update -n base -c defaults conda ## Package Plan ## environment location: E:\anaconda3\envs\tensorflow-gpu added / updated specs: - tensorflow-gpu The following packages will be downloaded: package | build ---------------------------|----------------- pyasn1-0.4.8 | py_0 58 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main requests-2.22.0 | py37_1 90 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main pysocks-1.7.1 | py37_0 30 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main zlib-1.2.11 | h62dcd97_3 128 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
居然就安装成功了,还以为会报cuda的错呢
chardet-3.0.4 | 192 KB | ############################################################################ | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
(tensorflow-gpu) C:\Users\shan-dell>
(tensorflow-gpu) C:\Users\shan-dell>python
Python 3.7.0 (default, Jun 28 2018, 08:04:48) [MSC v.1912 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
2020-02-27 12:51:35.107089: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
查看了一下conda给我装的清华镜像的tensorflow-gpu的版本
我去,tensorflow-gpu2.1.0,版本这么高,有点可怕
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。