安装了GPU支持的Caffe-SSD抛出错误“无法在仅CPU的Caffe中使用GPU”

时间:2018-08-20 09:35:34

标签: caffe

我已经安装了caffe-ssd和OpenCV版本3.2.0,CUDA版本9.2.148和CuDNN版本7.2.1.38。

这些是我在Makefile.config中的设置

# cuDNN acceleration switch (uncomment to build with cuDNN).
USE_CUDNN := 1

# CPU-only switch (uncomment to build without GPU support).
# CPU_ONLY := 1

# Uncomment if you're using OpenCV 3
OPENCV_VERSION := 3

# We need to be able to find Python.h and numpy/arrayobject.h.
PYTHON_INCLUDE := /usr/include/python2.7 \
        /usr/local/lib/python2.7/dist-packages/numpy/core/include

# Uncomment to support layers written in Python (will link against    Python libs)
WITH_PYTHON_LAYER := 1

# Whatever else you find you need goes here.
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial/

所有测试均通过。

[----------] Global test environment tear-down
[==========] 1266 tests from 168 test cases ran. (45001 ms total)
[  PASSED  ] 1266 tests.

此后,我遵循此link进行SSD操作。 LMDB创建工作正常,但是当我运行

python examples/ssd/ssd_pascal.py

我收到以下错误

I0820 14:16:29.089138 22429 caffe.cpp:217] Using GPUs 0
F0820 14:16:29.089301 22429 common.cpp:66] Cannot use GPU in CPU-only Caffe: check mode.
*** Check failure stack trace: ***
    @     0x7f97322a00cd  google::LogMessage::Fail()
    @     0x7f97322a1f33  google::LogMessage::SendToLog()
    @     0x7f973229fc28  google::LogMessage::Flush()
    @     0x7f97322a2999  google::LogMessageFatal::~LogMessageFatal()
    @     0x7f973284f8a0  caffe::Caffe::SetDevice()
    @     0x55b05fe50dcb  (unknown)
    @     0x55b05fe4c543  (unknown)
    @     0x7f9730ae3b97  __libc_start_main
    @     0x55b05fe4cffa  (unknown)
Aborted (core dumped)

我有NVIDIA GeForce GTX 1080 Ti显卡。

Mon Aug 20 14:26:48 2018       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 396.51                 Driver Version: 396.51                    |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 108...  Off  | 00000000:01:00.0 Off |                  N/A |
| 44%   37C    P8    19W / 250W |     18MiB / 11177MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0      1356      G   /usr/lib/xorg/Xorg                             9MiB |
|    0      1391      G   /usr/bin/gnome-shell                           6MiB |
+-----------------------------------------------------------------------------+

我尝试使用nvcc编译一个简单的Cuda代码,然后毫无问题地运行它。我可以import caffe,没有任何问题。

我已经检查了this个问题,但这不是我的问题。

1 个答案:

答案 0 :(得分:0)

对于错误错误== cudaSuccess(7对0)

在ssd_pascal.py中从gpus = "0,1,2,3"更改为gpus = "0",并在Makefile.config的 CUDA_DIR 中检查cuda的路径,并使用正确的路径和版本进行更新已安装在您的系统中。

并且由于错误“不能在仅CPU的Caffe中使用GPU”,使用make test命令再次构建ssd