tensorflow Mac OS gpu支持 [英] tensorflow Mac OS gpu support
问题描述
根据
https://www.tensorflow.org/install/install_mac 注意:从版本开始1.2,TensorFlow不再在Mac OS X上提供GPU支持. 不再提供对OS X的GPU支持.
https://www.tensorflow.org/install/install_mac Note: As of version 1.2, TensorFlow no longer provides GPU support on Mac OS X. GPU support for OS X is no longer provided.
但是,我想通过雷电3运行带有1080 ti的akitio节点之类的e-gpu设置.
However, I would want to run an e-gpu setup like akitio node with a 1080 ti via thunderbolt 3.
要使此设置正常工作,需要执行哪些步骤? 到目前为止,我知道
What steps are required to get this setup to work? So far I know that
- 禁用SIP
- 运行自动化e-gpu脚本 https://github.com/goalque/automate-eGPU
是必需的.要使CUDA/tensorflow正常工作还需要什么?
are required. What else is needed to get CUDA / tensorflow to work?
推荐答案
I wrote a little tutorial on compiling TensorFlow 1.2 with GPU support on macOS. I think it's customary to copy relevant parts to SO, so here it goes:
- 如果您以前没有使用过TensorFlow-GPU设置,建议您先使用TensorFlow 1.0或1.1进行所有设置,然后仍然可以执行
pip install tensorflow-gpu
.一旦完成该工作,如果您正在编译TensorFlow,CUDA设置也将起作用.如果您有外部GPU,请使用YellowPillow的答案(或从源代码安装TensorFlow ",但显然可以用git checkout r1.0
代替git checkout r1.2
. 在执行./configure
时,请注意Python库路径:有时提示不正确.在大多数情况下,我选择了默认选项,但以下选项除外:Python库路径,CUDA支持和计算能力.不要将Clang用作CUDA编译器:这将导致您出现错误"crosstool配置不一致;没有为CPU"darwin"找到与"local_darwin"相对应的工具链.".使用/usr/bin/gcc
作为编译器实际上将使用macOS/XCode随附的Clang.以下是我的完整配置. - TensorFlow 1.2需要一个名为OpenMP的C库,该库在当前的Apple Clang中不可用.它应该可以在多CPU机器上加快多线程TensorFlow的运行,但是如果没有它,它也会进行编译.我们可以尝试使用gcc 4(我没有管理过)构建TensorFlow,或者从构建文件中删除包含OpenMP的行.就我而言,我注释了
tensorflow/third_party/gpus/cuda/BUILD.tpl
的第98行,该行又是contained linkopts = [-lgomp]
(但是该行的位置可能明显改变了).有些人 zmuldefs出现了问题,但我认为这是早期版本的问题;感谢udnaan指出可以注释掉这些行. - 在使用最新的bazel 0.5.3进行构建时遇到了一些问题,因此我恢复为使用已经安装的0.4.5.但是在github问题中的一些讨论提到bazel 0.5.2也没有问题.
- 现在使用bazel进行构建,并按照官方安装指南的说明完成安装.在我的3.2 GHz iMac上,此过程耗时约37分钟.
- If you haven’t used a TensorFlow-GPU set-up before, I suggest first setting everything up with TensorFlow 1.0 or 1.1, where you can still do
pip install tensorflow-gpu
. Once you get that working, the CUDA set-up would also work if you’re compiling TensorFlow. If you have an external GPU, YellowPillow's answer (or mine) might help you get things set up. - Follow the official tutorial "Installing TensorFlow from Sources", but obviously substitute
git checkout r1.0
withgit checkout r1.2
. When doing./configure
, pay attention to the Python library path: it sometimes suggests an incorrect one. I chose the default options in most cases, except for: Python library path, CUDA support and compute capacity. Don’t use Clang as the CUDA compiler: this will lead you to an error "Inconsistent crosstool configuration; no toolchain corresponding to 'local_darwin' found for cpu 'darwin'.". Using/usr/bin/gcc
as your compiler will actually use Clang that comes with macOS / XCode. Below is my full configuration. - TensorFlow 1.2 expects a C library called OpenMP, which is not available in the current Apple Clang. It should speed up multithreaded TensorFlow on multi-CPU machines, but it will also compile without it. We could try to build TensorFlow with gcc 4 (which I didn’t manage), or simply remove the line that includes OpenMP from the build file. In my case I commented out line 98 of
tensorflow/third_party/gpus/cuda/BUILD.tpl
, whichcontained linkopts = ["-lgomp"]
(but the location of the line might obviously change). Some people had issues with zmuldefs, but I assume that was with earlier versions; thanks to udnaan for pointing out that it’s OK to comment out these lines. - I had some problems building with the latest bazel 0.5.3, so I reverted to using 0.4.5 that I already had installed. But some discussion in a github issue mentioned bazel 0.5.2 also didn’t have the problem.
- Now build with bazel and finish the installation as instructed by the official install guide. On my 3.2 GHz iMac this took about 37 minutes.
使用python库路径:/Users/m/code/3rd/conda/envs/p3gpu/lib/python3.6/site-packages
Using python library path: /Users/m/code/3rd/conda/envs/p3gpu/lib/python3.6/site-packages
您是否希望在MKL支持下构建TensorFlow? [y/N] N
Do you wish to build TensorFlow with MKL support? [y/N] N
TensorFlow不会启用MKL支持
No MKL support will be enabled for TensorFlow
请指定在指定bazel选项"--config = opt"时在编译过程中使用的优化标志[默认为-march = native]:
Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is -march=native]:
您是否希望使用Google Cloud Platform支持构建TensorFlow? [y/N]
Do you wish to build TensorFlow with Google Cloud Platform support? [y/N]
将不会为TensorFlow启用Google Cloud Platform支持
No Google Cloud Platform support will be enabled for TensorFlow
您是否希望使用Hadoop File System支持构建TensorFlow? [y/N]
Do you wish to build TensorFlow with Hadoop File System support? [y/N]
将不会为TensorFlow启用Hadoop文件系统支持
No Hadoop File System support will be enabled for TensorFlow
您是否希望使用XLA即时编译器(实验性)构建TensorFlow? [y/N]
Do you wish to build TensorFlow with the XLA just-in-time compiler (experimental)? [y/N]
不会为TensorFlow启用XLA支持
No XLA support will be enabled for TensorFlow
您想构建具有VERBS支持的TensorFlow吗? [y/N]
Do you wish to build TensorFlow with VERBS support? [y/N]
不会为TensorFlow启用VERBS支持
No VERBS support will be enabled for TensorFlow
您是否希望使用OpenCL支持构建TensorFlow? [y/N]
Do you wish to build TensorFlow with OpenCL support? [y/N]
不会为TensorFlow启用OpenCL支持
No OpenCL support will be enabled for TensorFlow
您是否希望在具有CUDA支持的情况下构建TensorFlow? [y/N] y
Do you wish to build TensorFlow with CUDA support? [y/N] y
将为TensorFlow启用CUDA支持
CUDA support will be enabled for TensorFlow
您要使用clang作为CUDA编译器吗? [y/N]
Do you want to use clang as CUDA compiler? [y/N]
nvcc将用作CUDA编译器
nvcc will be used as CUDA compiler
请指定您要使用的CUDA SDK版本,例如7.0. [留空以使用系统默认值]:
Please specify the CUDA SDK version you want to use, e.g. 7.0. [Leave empty to use system default]:
请指定CUDA工具包的安装位置.有关更多详细信息,请参考README.md. [默认值为/usr/local/cuda]:
Please specify the location where CUDA toolkit is installed. Refer to README.md for more details. [Default is /usr/local/cuda]:
请指定nvcc应使用哪个gcc作为主机编译器. [默认值为/usr/bin/gcc]:
Please specify which gcc should be used by nvcc as the host compiler. [Default is /usr/bin/gcc]:
请指定您要使用的cuDNN版本. [留空以使用系统默认值]:
Please specify the cuDNN version you want to use. [Leave empty to use system default]:
请指定cuDNN库的安装位置.有关更多详细信息,请参考README.md. [默认值为/usr/local/cuda]:
Please specify the location where cuDNN library is installed. Refer to README.md for more details. [Default is /usr/local/cuda]:
请指定要使用的逗号分隔的Cuda计算功能列表.
Please specify a list of comma-separated Cuda compute capabilities you want to build with.
您可以在以下位置找到设备的计算能力: https://developer.nvidia.com/cuda -gpus .
You can find the compute capability of your device at: https://developer.nvidia.com/cuda-gpus.
请注意,每种额外的计算功能都会显着增加构建时间和二进制文件大小.
Please note that each additional compute capability significantly increases your build time and binary size.
[默认值为:"3.5,5.2"]:6.1
[Default is: "3.5,5.2"]: 6.1
信息:开始清理(这可能需要一段时间).如果清理时间超过几分钟,请考虑使用--async.
INFO: Starting clean (this may take a while). Consider using --async if the clean takes more than several minutes.
配置完成
这篇关于tensorflow Mac OS gpu支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!