Anaconda+Linux(Ubuntu) 安装指定版本tensorflow(GPU)
创建环境conda create -n envs_name python=版本号 #其中的envs_name是需要创建的环境名其中的版本号最好加上,当所配置环境使用的python版本和anconda中的python版本一致时,anconda3/envs/envs_name文件夹中的
·
创建和删除环境
- 创建环境
conda create -n envs_name python=版本号 #其中的envs_name是需要创建的环境名
其中的python=版本号
最好加上,当所配置环境使用的python版本和anconda中的python版本一致时,anaconda3/envs/envs_name文件夹中会出现空文件夹的情况,导致在pycharm中配置python解释器时找不到python文件。
- 删除环境
conda remove -n envs_name --all
配置环境
- 自动安装最新版本tensorflow
直接使用命令pip3 install tensorflow
会安装最新版本tensorflow
也可以使用命令conda install tensorflow
来进行安装(但是使用conda安装版本可能会不全) - 安装指定版本tensorflow
对于2.0及以上版本,不用指定cpu或者gpu版本,系统自己会选择安装,而对于2.0以下版本,安装时需要指定安装的是cpu还是gpu版 本。命令如下:
#2.0及以上版本(以2.6.0为例):
pip3 install tensorflow==2.6.0 #将2.6.0更换为需要安装的版本
#2.0以下版本(以1.14.0为例):
pip3 install tensorflow-gpu==1.14.0 #将1.14.0更换为需要安装的版本
- tensorflow版本列表
tensoflow版本列表
进入网站后点击左侧Linux/macOS
,往下滑就能看见列表
出现的问题
- tensorflow版本与numpy版本不匹配
在安装完tensorflow1.14.0版本之后,import tensorflow as tf
时出现了以下警告:
Python 3.7.13 (default, Mar 29 2022, 02:18:16)
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
/home/xiaochen/anaconda3/envs/tensorflow-V1/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:516: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint8 = np.dtype([("qint8", np.int8, 1)])
/home/xiaochen/anaconda3/envs/tensorflow-V1/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:517: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint8 = np.dtype([("quint8", np.uint8, 1)])
/home/xiaochen/anaconda3/envs/tensorflow-V1/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:518: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint16 = np.dtype([("qint16", np.int16, 1)])
/home/xiaochen/anaconda3/envs/tensorflow-V1/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:519: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint16 = np.dtype([("quint16", np.uint16, 1)])
/home/xiaochen/anaconda3/envs/tensorflow-V1/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:520: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint32 = np.dtype([("qint32", np.int32, 1)])
/home/xiaochen/anaconda3/envs/tensorflow-V1/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:525: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
np_resource = np.dtype([("resource", np.ubyte, 1)])
/home/xiaochen/anaconda3/envs/tensorflow-V1/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:541: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint8 = np.dtype([("qint8", np.int8, 1)])
/home/xiaochen/anaconda3/envs/tensorflow-V1/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:542: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint8 = np.dtype([("quint8", np.uint8, 1)])
/home/xiaochen/anaconda3/envs/tensorflow-V1/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:543: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint16 = np.dtype([("qint16", np.int16, 1)])
/home/xiaochen/anaconda3/envs/tensorflow-V1/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:544: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint16 = np.dtype([("quint16", np.uint16, 1)])
/home/xiaochen/anaconda3/envs/tensorflow-V1/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:545: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint32 = np.dtype([("qint32", np.int32, 1)])
/home/xiaochen/anaconda3/envs/tensorflow-V1/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:550: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
np_resource = np.dtype([("resource", np.ubyte, 1)])
>>>
出现以上警告的原因是numpy版本过高
解决办法是安装低版本的numpy
pip install numpy==1.16.0 #对应tensorflow1.14.0安装numpy1.16.0
更多推荐
已为社区贡献1条内容
所有评论(0)