首页 > 解决方案 > 为什么我不能在 mac 上导入 tensorflow-gpu?

问题描述

我是新来这里发帖的,所以如果我搞砸了,请原谅我。我一直在尝试在 Mac OS 10.12.6 上安装支持 gpu 的 tensorflow。我知道 Tensorflow for mac 支持从 1.2 版开始被删除。我正在安装 1.1.0 版。我能够安装这个版本,但是,当我尝试导入 tensorflow 时,我得到以下堆栈跟踪:

import tensorflow as tf

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/workhorse/tensorflow-gpu/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
  File "/Users/workhorse/tensorflow-gpu/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 51, in <module>
from tensorflow.python import pywrap_tensorflow
  File "/Users/workhorse/tensorflow-gpu/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 52, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "/Users/workhorse/tensorflow-gpu/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
  File "/Users/workhorse/tensorflow-gpu/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
  File "/Users/workhorse/tensorflow-gpu/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
ImportError: dlopen(/Users/workhorse/tensorflow-gpu/lib/python2.7/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so, 10): Library not loaded: @rpath/libcublas.8.0.dylib
  Referenced from: /Users/workhorse/tensorflow-gpu/lib/python2.7/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so
  Reason: image not found


Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/install_sources#common_installation_problems

for some common reasons and solutions.  Include the entire stack trace
above this error message when asking for help.

我检查了常见的原因,但没有人提到我的原因。感谢您的时间和帮助!

标签: pythonmacostensorflowgpu

解决方案


根据 GitHub URL,这里看起来可能有修复

根据其中一位用户的说法,这似乎是一个流行的答案:

以下用户

我只是做了一些研究,我并没有真正为您的答案提供任何见解,如果不让我知道,希望对您有所帮助。


推荐阅读