Anaconda环境下玩TensorFlow2.6.2

一 安装TensorFlow

首先安装anaconda,这个网上很多教程,登录官网下载安装即可。

查看anaconda 安装过的环境

conda env list

创建指定python版本的conda环境

conda create --lee3.6 conda_tf python=3.6

进入conda环境和离开环境

conda activate lee3.6
conda deactivate

进入环境后安装TensorFlow

安装TensorFlow 出现错误,是在环境下安装

conda create -n tf tensorflow-gpu

如果有error下面的提示是缺乏-n表示指定名字,-p表示指定安装路径。

conda-script.py create: error: one of the arguments -n/--name -p/--prefix is required

安装成功!

done
#
# To activate this environment, use
#
#     $ conda activate tf
#
# To deactivate an active environment, use
#
#     $ conda deactivate

在python环境下无法import TensorFlow,无法pip list命令
但是直接conda activate tf又可以,不是应该在python下导入并使用TensorFlow吗,还是说没有安装在python的库路径里?
import时候各种错误,各种缺dll,查了有人说是什么32位64位版本拉,什么python版本不对拉,搞不懂

pip install tensorflow-gpu

运行后各种错误,,前功尽弃
看提示是说不用加gpu后缀了,一样的

The "tensorflow-gpu" package has been removed!

    Please install "tensorflow" instead.

    Other than the name, the two packages have been identical
    since TensorFlow 2.1, or roughly since Sep 2019. For more
    information, see: pypi.org/project/tensorflow-gpu

最后出动大杀器https://tensorflow.google.cn/install?hl=zh-cn
感谢党,这个网址还能打开。直接运行pip install tensorflow

(lee3.6) C:\Users\new>pip install tensorflow
Collecting tensorflow
  Downloading tensorflow-2.6.2-cp36-cp36m-win_amd64.whl (423.3 MB)
     |████████████████████████████████| 423.3 MB 16 kB/s

等待安装完成后试试


(lee3.6) C:\Users\new>python
Python 3.6.15 (default, Dec  3 2021, 18:25:24) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
2023-04-13 12:53:57.104713: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found
2023-04-13 12:53:57.108891: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
>>>
KeyboardInterrupt
>>>

貌似是说安装成功了?缺的dll文件到https://www.dll-files.com/search/搜索
放到目录里C:\Windows\System32 (Windows XP, Vista, 7, 8, 8.1, 10).
把dll文件补全后:再次import。没有报错。
有个文章说是TensorFlow版本过高,要再安装低版本,我信你个鬼。

>>> tf.__version__
'2.6.2'

注意是俩个下划线。

二 在pycharm里面配置一下

new一个新的project testtf
然后file菜单-》setting
在Project:testtf条目下
点击Python interpreter
选择已经配置好TensorFlow的conda环境
在pycharm里面import一下TensorFlow
右键-》run。没有报错。

三出现缺dll库暂时未解决

四 网上建议的安装包

# Quick and dirty: with channel specification
conda create -n tf_gpu_env python=3.8 
conda activate tf_gpu_env
conda install tensorflow-gpu -c anaconda
conda install cudnn -c conda-forge 
conda install cudatoolkit -c anaconda

五 创建conda 环境报错

conda create lee3.6 -n python=3.6
报错OpenSSL appears to be unavailable on this machine

在安装目录下E:\ProgramData\Anaconda3\Library\bin
拷贝俩个dll文件libcrypto-1_1-x64.dll、libssl-1_1-x64.dll
复制到E:\ProgramData\Anaconda3\DLLs

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值