安装后没有名为tensorflow的模块吗?

时间:2018-12-17 20:18:40

标签: tensorflow pycharm

我安装了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)

1 个答案:

答案 0 :(得分:1)

您将要配置解释器src

  

1)在“项目解释器”页面中,选择已配置的解释器或虚拟环境之一。

     

2)单击编辑。

     

3)在打开的“编辑Python解释器”对话框中,键入所需的解释器名称。       更改口译员的名字

     

在“名称”字段中指定的Python解释器名称在可用解释器列表中可见。

     

如有必要,请更改Python可执行文件的路径。