解决conda环境下import TensorFlow失败的问题

问题描述

安装了anaconda的电脑,新建了一个名叫deeplearning的环境,在该环境下已经成功安装了tensorflow。

于是在终端打开python并执行代码

python 复制代码
import tensorflow as tf
print(1)

除了提示

shell 复制代码
2024-02-27 21:50:00.801427: I external/local_tsl/tsl/cuda/cudart_stub.cc:31] Could not find cuda drivers on your machine, GPU will not be used.
2024-02-27 21:50:00.838675: E external/local_xla/xla/stream_executor/cuda/cuda_dnn.cc:9261] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered
2024-02-27 21:50:00.838709: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:607] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered
2024-02-27 21:50:00.839681: E external/local_xla/xla/stream_executor/cuda/cuda_blas.cc:1515] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered
2024-02-27 21:50:00.845214: I external/local_tsl/tsl/cuda/cudart_stub.cc:31] Could not find cuda drivers on your machine, GPU will not be used.
2024-02-27 21:50:00.845380: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2024-02-27 21:50:01.529134: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
1

错误提示是代表没有安装TensorRT,暂时忽略,可以看出已经打印了1,已经安装成功。

但是运行juypter-notebook后,会提示

shell 复制代码
ModuleNotFoundError: No module named 'tensorflow'

原因

在新建环境下,没有安装juypter-notebook,导致运行的juypter-notebook实际上仍然是base环境下的,因此失败

解决

shell 复制代码
conda activate deeplearning
conda install nb_conda

这样就在deeplearning安装了juypter-notebook了。

问题解决。

相关推荐
deephub9 分钟前
5个开源MCP服务器:扩展AI助手能力,高效处理日常工作
人工智能·深度学习·大语言模型·mcp
Ai野生菌10 分钟前
MCP专题 | 探索MCP服务器世界:增强AI能力的精选推荐
服务器·人工智能·mcp·mcp server
乌旭28 分钟前
去中心化算力池:基于IPFS+智能合约的跨校GPU资源共享平台设计
人工智能·深度学习·架构·去中心化·区块链·智能合约·risc-v
巷9551 小时前
OpenCV阈值处理完全指南:从基础到高级应用
人工智能·opencv·计算机视觉
知舟不叙1 小时前
基于OpenCV的SIFT特征和FLANN匹配器的指纹认证
人工智能·opencv·计算机视觉·sift·指纹认证
liuyang-neu1 小时前
目标检测DINO-DETR(2023)详细解读
人工智能·目标检测·计算机视觉
学术科研小助手2 小时前
【计算机方向海外优质会议推荐】第二届图像处理、机器学习与模式识别国际学术会议(IPMLP 2025)
图像处理·人工智能·机器学习
三道杠卷胡2 小时前
【AI News | 20250520】每日AI进展
人工智能·pytorch·python·语言模型·github
源码方舟2 小时前
【小明剑魔视频Viggle AI模仿的核心算法组成】
人工智能·算法·音视频
人工智能与智能制造2 小时前
基于大模型与人工智能体的机械臂对话式交互系统RobotAgent
人工智能·语言模型·交互