我遇到了一个恼人的错误。
You can find the C code in this temporary file: /tmp/theano_compilation_error_ppkcgkmi Traceback (most recent call last): File "/home/ubuntu/my_project/venv/lib/python3.6/site-packages/theano/gof/lazylinker_c.py", line 75, in raise ImportError() ImportError
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/home/ubuntu/my_project/venv/lib/python3.6/site-packages/theano/gof/lazylinker_c.py", line 92, in raise ImportError() ImportError
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "", line 1, in File "/home/ubuntu/my_project/venv/lib/python3.6/site-packages/theano/init.py", line 110, in from theano.compile import ( File "/home/ubuntu/my_project/venv/lib/python3.6/site-packages/theano/compile/init.py", line 12, in from theano.compile.mode import * File "/home/ubuntu/my_project/venv/lib/python3.6/site-packages/theano/compile/mode.py", line 11, in import theano.gof.vm File "/home/ubuntu/my_project/venv/lib/python3.6/site-packages/theano/gof/vm.py", line 673, in from . import lazylinker_c File "/home/ubuntu/my_project/venv/lib/python3.6/site-packages/theano/gof/lazylinker_c.py", line 127, in preargs=args) File "/home/ubuntu/my_project/venv/lib/python3.6/site-packages/theano/gof/cmodule.py", line 2359, in compile_str (status, compile_stderr.replace('\n', '. '))) Exception: Compilation failed (return status=1): /home/ubuntu/.theano/compiledir_Linux-4.4--aws-x86_64-with-Ubuntu-16.04-xenial-x86_64-3.6.4-64/lazylinker_ext/mod.cpp:1:20: fatal error: Python.h: No such file or directory. compilation terminated..
我使用的是来自 AWS 的 P2 实例,我在其中安装了 Ubuntu 16.04。
我只是想在 python3.6.4 上import theano
我已经重新安装了 theano 很多次,我还安装了许多其他东西,但它不工作。
我有一个虚拟环境并且正在使用 GPU。
我假设我的 GPU-CUDA-CuNN 已经安装好
>>> sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
2018-03-07 17:56:48.738855: I tensorflow/core/platform/cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2018-03-07 17:56:51.390598: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:898] 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-03-07 17:56:51.390927: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1212] Found device 0 with properties:
name: Tesla K80 major: 3 minor: 7 memoryClockRate(GHz): 0.8235
pciBusID: 0000:00:1e.0
totalMemory: 11.17GiB freeMemory: 11.10GiB
2018-03-07 17:56:51.390955: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1312] Adding visible gpu devices: 0
2018-03-07 17:56:51.656494: I tensorflow/core/common_runtime/gpu/gpu_device.cc:993] Creating TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 10764 MB memory) -> physical GPU (device: 0, name: Tesla K80, pci bus id: 0000:00:1e.0, compute capability: 3.7)
Device mapping:
/job:localhost/replica:0/task:0/device:GPU:0 -> device: 0, name: Tesla K80, pci bus id: 0000:00:1e.0, compute capability: 3.7
2018-03-07 17:56:51.787214: I tensorflow/core/common_runtime/direct_session.cc:297] Device mapping:
/job:localhost/replica:0/task:0/device:GPU:0 -> device: 0, name: Tesla K80, pci bus id: 0000:00:1e.0, compute capability: 3.7
在我的本地机器上一切正常,但在 aws 实例上它存储在那里,这是我第一次遇到这个错误。
我希望有人已经看到了这种错误。
编辑
我为我的项目解决了这个问题,因为我只需要 Tensorflow 并且不知何故有人从 theano 而不是从 numpy 导入了 np。但是,这仍然是一个奇怪的问题,我想知道如何解决它。可能是numpy的版本问题?
lazylinker_c.py 中的 75 行只是比较两个版本。我不知道。
请您参考如下方法:
当我尝试从 Python 3.5 迁移到 Python 3.6 时,我在使用 Ubuntu 16.04 时遇到了同样的问题。最后我发现 Ubuntu 16.04 不包含标准的 Python 3.6 的 C 头文件,因此需要单独安装它们。 theano 库以某种方式使用 C 进行某些计算。运行此命令:
sudo apt-get install python3.6-dev
为我解决了问题。
