CUDA在mac上找不到GPU

时间:2017-01-12 14:30:44

标签: macos python-3.x cuda tensorflow gpu

几天前,我已经设法让CUDA使用GeForce GTX 780M在我的mac上使用tensorflow。但是今天我注意到它不再有效了。我不确定发生了什么变化,但我已经确认库(特别是cudann)仍然正确安装。

重新启动或重新安装tensorflow都没有帮助(我从https://storage.googleapis.com/tensorflow/mac/gpu/tensorflow_gpu-0.12.1-py3-none-any.whl安装了tensorflow)这是从tensorflow网站运行mnist示例的输出:

I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcublas.dylib locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcudnn.dylib locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcufft.dylib locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcuda.1.dylib locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcurand.dylib locally
Extracting MNIST_data/train-images-idx3-ubyte.gz
Extracting MNIST_data/train-labels-idx1-ubyte.gz
Extracting MNIST_data/t10k-images-idx3-ubyte.gz
Extracting MNIST_data/t10k-labels-idx1-ubyte.gz
E tensorflow/stream_executor/cuda/cuda_driver.cc:509] failed call to cuInit: CUDA_ERROR_NO_DEVICE
I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:158] retrieving CUDA diagnostic information for host: Net-iMac-3.local
I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:165] hostname: Net-iMac-3.local
I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:189] libcuda reported version is: 310.42.25
I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:193] kernel reported version is: Invalid argument: expected %d.%d or %d.%d.%d form for driver version; got ""
step 0, training accuracy 0.06

以下是nvcc -V的输出:

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2016 NVIDIA Corporation
Built on Sun_Oct_30_22:18:43_CDT_2016
Cuda compilation tools, release 8.0, V8.0.54

输出:ls -l /usr/local/cuda/lib/libcud*

lrwxr-xr-x  1 mik   admin    33B Jan  7 16:29 /usr/local/cuda/lib/libcuda.1.dylib -> /usr/local/cuda/lib/libcuda.dylib
-rwxr-xr-x@ 1 root  wheel    13K Nov  3 19:39 /usr/local/cuda/lib/libcuda.dylib
lrwxr-xr-x@ 1 root  wheel    45B Nov  3 19:40 /usr/local/cuda/lib/libcudadevrt.a -> /Developer/NVIDIA/CUDA-8.0/lib/libcudadevrt.a
lrwxr-xr-x@ 1 root  wheel    50B Nov  3 19:40 /usr/local/cuda/lib/libcudart.8.0.dylib -> /Developer/NVIDIA/CUDA-8.0/lib/libcudart.8.0.dylib
lrwxr-xr-x@ 1 root  wheel    46B Nov  3 19:40 /usr/local/cuda/lib/libcudart.dylib -> /Developer/NVIDIA/CUDA-8.0/lib/libcudart.dylib
lrwxr-xr-x@ 1 root  wheel    49B Nov  3 19:40 /usr/local/cuda/lib/libcudart_static.a -> /Developer/NVIDIA/CUDA-8.0/lib/libcudart_static.a
-rwxr-xr-x@ 1 mik   staff    74M Jul 27 09:18 /usr/local/cuda/lib/libcudnn.5.dylib
lrwxr-xr-x@ 1 mik   staff    16B Jul 27 09:21 /usr/local/cuda/lib/libcudnn.dylib -> libcudnn.5.dylib
-rw-r--r--@ 1 mik   staff    63M Jul 27 09:18 /usr/local/cuda/lib/libcudnn_static.a

我尝试重新安装驱动程序,安装旧驱动程序,但没有任何帮助

根据https://github.com/aymericdamien/TensorFlow-Examples/issues/38我执行export CUDA_VISIBLE_DEVICES=1以防止运行tensorflow时出现内存问题。如果我然后运行./deviceQuery则无法找到gpu:

/Developer/NVIDIA/CUDA-8.0/samples/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

但是,如果我运行export CUDA_VISIBLE_DEVICES=0,则运行./deviceQuery会给出:

/Developer/NVIDIA/CUDA-8.0/samples/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 GTX 780M"
  CUDA Driver Version / Runtime Version          8.0 / 8.0
  CUDA Capability Major/Minor version number:    3.0
  Total amount of global memory:                 4096 MBytes (4294508544 bytes)
  ( 8) Multiprocessors, (192) CUDA Cores/MP:     1536 CUDA Cores
  GPU Max Clock rate:                            784 MHz (0.78 GHz)
  Memory Clock rate:                             2500 Mhz
  Memory Bus Width:                              256-bit
  L2 Cache Size:                                 524288 bytes
  Maximum Texture Dimension Size (x,y,z)         1D=(65536), 2D=(65536, 65536), 3D=(4096, 4096, 4096)
  Maximum Layered 1D Texture Size, (num) layers  1D=(16384), 2048 layers
  Maximum Layered 2D Texture Size, (num) layers  2D=(16384, 16384), 2048 layers
  Total amount of constant memory:               65536 bytes
  Total amount of shared memory per block:       49152 bytes
  Total number of registers available per block: 65536
  Warp size:                                     32
  Maximum number of threads per multiprocessor:  2048
  Maximum number of threads per block:           1024
  Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
  Max dimension size of a grid size    (x,y,z): (2147483647, 65535, 65535)
  Maximum memory pitch:                          2147483647 bytes
  Texture alignment:                             512 bytes
  Concurrent copy and kernel execution:          Yes with 2 copy engine(s)
  Run time limit on kernels:                     Yes
  Integrated GPU sharing Host Memory:            No
  Support host page-locked memory mapping:       Yes
  Alignment requirement for Surfaces:            Yes
  Device has ECC support:                        Disabled
  Device supports Unified Addressing (UVA):      Yes
  Device PCI Domain ID / Bus ID / location ID:   0 / 1 / 0
  Compute Mode:
     < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >

deviceQuery, CUDA

1 个答案:

答案 0 :(得分:3)

“CUDA_VISIBLE_DEVICES = 1”表示Cuda只能在您的计算机上看到gpu_1。你有两个GPU吗? “nvidia-smi”展示了什么?

通常,如果要使用“CUDA_VISIBLE_DEVICES”,请确保指向要使用的GPU。