我根据官方指示在macOS上使用来自python源的GPU支持构建了tensorflow。当我导入tensorflow时,我没有得到我在使用pip版本时所做的典型CUDA加载消息(如下所示)。
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcublas.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcudnn.so.5 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcufft.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcurand.so.8.0 locally
但是,当我使用我的构建运行我的测试程序时,我确实看到GPU正在被找到并使用(我认为)。
~/Drive/thesis/image_keras$ python3 demo.py
Using TensorFlow backend.
Found 2125 images belonging to 2 classes.
Found 832 images belonging to 2 classes.
demo.py:64: UserWarning: Update your `fit_generator` call to the Keras 2 API: `fit_generator(<keras.pre..., validation_data=<keras.pre..., steps_per_epoch=128, epochs=25, validation_steps=832)`
nb_val_samples=nb_validation_samples)
Epoch 1/25
2017-04-13 08:39:24.542434: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:865] OS X does not support NUMA - returning NUMA node zero
2017-04-13 08:39:24.542538: I tensorflow/core/common_runtime/gpu/gpu_device.cc:887] Found device 0 with properties:
name: GeForce GT 750M
major: 3 minor: 0 memoryClockRate (GHz) 0.9255
pciBusID 0000:01:00.0
Total memory: 2.00GiB
Free memory: 1.77GiB
2017-04-13 08:39:24.542551: I tensorflow/core/common_runtime/gpu/gpu_device.cc:908] DMA: 0
2017-04-13 08:39:24.542557: I tensorflow/core/common_runtime/gpu/gpu_device.cc:918] 0: Y
2017-04-13 08:39:24.542566: I tensorflow/core/common_runtime/gpu/gpu_device.cc:977] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GT 750M, pci bus id: 0000:01:00.0)
49/128 [==========>...................] - ETA: 18s - loss: 0.7352 - acc: 0.5166
看起来它使用GPU,但没有CUDA加载,我不确定。如果它有所作为,我正在使用CUDA-8.0
cuDNN-8.0-v5.1
答案 0 :(得分:0)
tensorflow.test.is_gpu_available()
tensorflow.test.is_built_with_cuda()
如果您运行这些代码,并且Tensorflow是使用CUDA构建的,则两个函数都应返回 True 。
我必须使用它,因为正如前面的答案所示,我没有得到一个输出&#34;成功打开CUDA库&#34;如图所示打印的行,即使我使用的是pip版本。 我使用的是Tensorflow 1.4.0。