1、首先确定是不是有Nvidia卡,简单查过最近几年的苹果,似乎都是Radeon
查看方法:左上角苹果LOGO -> 关于本机
2、确定GPU是不是支持CUDA
https://developer.nvidia.com/cuda-gpus
我的电脑是 GeForce GT 650M 3.0
3、下载,选择正确平台和OS版本
https://developer.nvidia.com/cuda-downloads
注意,现在有两个文件,cuda_8.0.61_mac.dmg、cuda_8.0.61.2_mac.dmg,后者是补丁
4、安装,参考:
http://docs.nvidia.com/cuda/cuda-installation-guide-mac-os-x/index.html
设置系统节能,保持显卡常开
安装后查看,似乎正常
quanzl-mac:samples flying$ kextstat | grep -i cuda
152 0 0xffffff7f82dff000 0x2000 0x2000 com.nvidia.CUDA (1.1.0) DD792765-CA28-395A-8593-D6837F05C4FF <4 1>
5、编译自带示例
由于系统都更新至最新,clang版本太新,nvcc不支持,它需要8.0。
根据安装文档,在 Apple Developer Download Page 下载Command Line Tools macOS 10.11 for Xcode 8.2.dmg
安装之后:
quanzl-mac:samples flying$ sudo xcode-select -s /Library/Developer/CommandLineTools
quanzl-mac:samples flying$ clang --version
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin16.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
6、编译 deviceQuery 查看设备
quanzl-mac:samples quanzl$ ./bin/x86_64/darwin/release/deviceQuery
./bin/x86_64/darwin/release/deviceQuery Starting...
CUDA Device Query (Runtime API) version (CUDART static linking)
cudaGetDeviceCount returned 38
-> no CUDA-capable device is detected
Result = FAIL
找不到!重新启动系统,仍然找不到。
7、打开 系统偏好设置 -> CUDA
这里有更新提示,更新到最新。
quanzl-mac:samples flying$ kextstat | grep -i cuda
156 0 0xffffff7f83a56000 0x2000 0x2000 com.nvidia.CUDA (1.1.0) DD792765-CA28-395A-8593-D6837F05C4FF <4 1>
8、一切正常
quanzl-mac:samples flying$ ./bin/x86_64/darwin/release/deviceQuery
./bin/x86_64/darwin/release/deviceQuery Starting...
CUDA Device Query (Runtime API) version (CUDART static linking)
Detected 1 CUDA Capable device(s)
Device 0: "GeForce GT 650M"
CUDA Driver Version / Runtime Version 8.0 / 8.0
CUDA Capability Major/Minor version number: 3.0
...
本文详细介绍了如何在Mac上安装并配置CUDA的过程,包括检查GPU型号、验证CUDA支持、下载安装CUDA驱动及运行示例程序等内容。


1万+


被折叠的 条评论
为什么被折叠?



