10.9的问题在于gcc
实际上是clang。请尝试使用最新的CUDA工具包,并明确指定NVCC使用/usr/bin/clang (nvcc -ccbin /usr/bin/clang)。这样NVCC将知道它正在处理clang。
· 在Mac OS X 10.8上安装XCode 5(包括命令行工具)后,gcc编译器将被clang替代。您可以通过使用--ccbin /usr/bin/clang选项从命令行继续成功地使用nvcc进行编译,该选项指示nvcc使用clang编译器而不是gcc编译器来编译传递给它的任何主机代码。但是,在使用NSight Eclipse Edition构建时,此解决方案将无法正常工作。一种可行的替代方案是在安装XCode 5后从Apple开发者网站下载旧版本的命令行工具包。这将重新安装gcc到/usr/bin。为了做到这一点,请转到
http://developer.apple.com/downloads/index.action
使用您的Apple ID登录,并在屏幕左侧的搜索窗格中搜索命令行工具。
这个问题实际上在OS X Mavericks之前就存在了,我在Moutain Lion时也遇到了同样的问题,Eugene的答案是100%正确的。
然而,自从升级到Mavericks以来,似乎我的Geforce显卡没有被识别为CUDA兼容设备,而且使用CUDA的软件用户也遇到了同样的问题。
因此最好现在不要进行更新。
随着OsX Maverick版本的发布,Clang成为了默认编译器,gcc和g++命令被重定向到Clang编译器。您可以通过Homebrew下载gcc编译器,并按照以下步骤将gcc和g++命令链接回gcc编译器。
$ brew install gcc48
[...]
$ sudo mkdir /usr/bin/backup && sudo mv /usr/bin/gcc /usr/bin/g++ /usr/bin/backup
$ sudo ln -s /usr/local/bin/gcc-4.8 /usr/bin/gcc
$ sudo ln -s /usr/local/bin/g++-4.8 /usr/bin/g++
我在这篇文章中找到了解决方案: http://gvsmirnov.ru/blog/tech/2014/02/07/building-openjdk-8-on-osx-maverick.html#all-you-had-to-do-was-follow-the-damn-train-cj
这是一个适用于Lion系统的Homebrew配方,我已经验证过可行。
$ brew cat memtestG80
require "formula"
# Documentation: https://github.com/Homebrew/homebrew/wiki/Formula-Cookbook
# /usr/local/Library/Contributions/example-formula.rb
# PLEASE REMOVE ALL GENERATED COMMENTS BEFORE SUBMITTING YOUR PULL REQUEST!
# Requires at compile time nvcc from https://developer.nvidia.com/cuda-downloads
# Requires popt at compile time
class Memtestg80 < Formula
homepage ""
url "https://github.com/ihaque/memtestG80/archive/master.zip"
sha1 ""
version "c4336a69fff07945c322d6c7fc40b0b12341cc4c"
# depends_on "cmake" => :build
depends_on :x11 # if your formula requires any X11/XQuartz components
def install
# ENV.deparallelize # if your formula fails when building in parallel
system "make", "-f", "Makefiles/Makefile.osx", "NVCC=/usr/local/cuda/bin/nvcc -ccbin /usr/bin/clang", "POPT_DIR=/usr/local/Cellar/popt/1.16/lib"
system "cp", "-a", "memtestG80", "/usr/local/bin"
end
test do
# `test do` will create, run in and delete a temporary directory.
#
# This test will fail and we won't accept that! It's enough to just replace
# "false" with the main program this formula installs, but it'd be nice if you
# were more thorough. Run the test with `brew test memtestG80`.
#
# The installed folder is not in the path, so use the entire path to any
# executables being tested: `system "#{bin}/program", "do", "something"`.
system "false"
end
end
-stdlib=libstdc ++
标志(如果直接指定给nvcc,则通过-Xcompiler)。 - kamjagin