tensorflow - 安装后没有名为 tensorflow 的模块?
问题描述
我安装了 tensorflow-gpu,但在 Pycharm 中出现错误:
ModuleNotFoundError: No module named 'tensorflow'
我在终端签入:
$ pip3 list|grep tensorflow
tensorflow-gpu 1.4.0
tensorflow-tensorboard 0.4.0
编辑:(使用venv安装后):
Successfully installed tensorflow-gpu-1.12.0
(venv) wojtek@wojtek-GF63-8RC:~$ python -c "import tensorflow as tf; tf.enable_eager_execution(); print(tf.reduce_sum(tf.random_normal([1000, 1000])))"
2018-12-17 21:49:14.893016: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2018-12-17 21:49:14.961123: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:964] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2018-12-17 21:49:14.961466: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1432] Found device 0 with properties:
name: GeForce GTX 1050 major: 6 minor: 1 memoryClockRate(GHz): 1.493
pciBusID: 0000:01:00.0
totalMemory: 3.95GiB freeMemory: 3.58GiB
2018-12-17 21:49:14.961479: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1511] Adding visible gpu devices: 0
2018-12-17 21:49:15.148507: I tensorflow/core/common_runtime/gpu/gpu_device.cc:982] Device interconnect StreamExecutor with strength 1 edge matrix:
2018-12-17 21:49:15.148538: I tensorflow/core/common_runtime/gpu/gpu_device.cc:988] 0
2018-12-17 21:49:15.148544: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1001] 0: N
2018-12-17 21:49:15.148687: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 3306 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1050, pci bus id: 0000:01:00.0, compute capability: 6.1)
tf.Tensor(918.94904, shape=(), dtype=float32)
解决方案
您需要配置解释器src
1) 在 Project Interpreters 页面中,选择已配置的解释器或虚拟环境之一。
2) 单击编辑。
3) 在打开的 Edit Python Interpreter 对话框中,键入所需的解释器名称。更改口译员姓名
在名称字段中指定的 Python 解释器名称在可用解释器列表中变得可见。
如有必要,更改 Python 可执行文件的路径。
推荐阅读
- kubernetes - 如何仅在给定部署的一个 pod 中添加注释?
- presto - 结构数组的 Presto 查询返回单个结构元素作为列而不是结构行
- language-agnostic - 光线从单个光源追踪整个 2D 网格
- swift - 在文本字段中输入文本并在按下按钮后让文本进入表格视图
- opencart - SquareUp 结账时定期付款
- opengl - 从 OpenGL Compute Shader 中的不同采样器读取会导致奇怪的像素化
- pandas - 有没有办法在 mongoDB 中插入数据框?
- javascript - 如何查找,我有什么样的 Javascript 错误?
- node.js - 当我运行 npm install 和 npm start 时,它不断出现以下消息
- python - 无法比较和管理 timedelta 对象