Caffe: How to set use one GPU

Created on 19 Dec 2014  路  12Comments  路  Source: BVLC/caffe

When I training my data. I come across segment error.I doubt imagenet use two GPU default.So I want to set one GPU. How to do it?

downstream problem?

Most helpful comment

I have the proble when i run :python examples/ssd/ssd_pascal.py
I solve the problem by vim examples/ssd/ssd_pascal.py modify

332 gpus = "0"

All 12 comments

I think you should define solver.prototxt like this : solver_mode:GPU and device_id:1
good luck :)

@Stewarttzy
Thanks,But It doesn't work. If I don't execute right.
I1219 15:59:41.169323 36602 caffe.cpp:99] Use GPU with device ID 1
F1219 15:59:41.175240 36602 common.cpp:137] Check failed: error == cudaSuccess (10 vs. 0) invalid device ordinal
* Check failure stack trace: *

Check if your Cuda is working or not. You can check it by running device query inside the Cuda. If your cuda is running, there may be permissive problem. Hence, if you are in Linux platform use "Sudo"... Cheers!!

you can first check the GPU that can available by "nvidia-smi", then you will know the "available idx"
, and set "device_id:available idx"

@Stewarttzy
Thanks,According you said. I input the 'nvidia-smi'.The output as following.Which is The "available idx"?
+------------------------------------------------------+
| NVIDIA-SMI 340.29 Driver Version: 340.29 |
|-------------------------------+----------------------+----------------------+
| 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 TIT... Off | 0000:05:00.0 N/A | N/A |
| 26% 26C P8 N/A / N/A | 40MiB / 6143MiB | N/A Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Compute processes: GPU Memory |
| GPU PID Process name Usage |
|=============================================================================|
| 0 Not Supported |
+-----------------------------------------------------------------------------+

@Stewarttzy I know the id.Thanks very much.
But I do the experiment. Segment error exists.When I use cpu. There is no the question.Could you help me?
* Aborted at 1418979043 (unix time) try "date -d @1418979043" if you are using GNU date *
PC: @ 0x7f119c5f3e74 (unknown)
* SIGSEGV (@0x0) received by PID 37741 (TID 0x7f11b44829c0) from PID 0; stack trace: *
@ 0x7f11b3017340 (unknown)
@ 0x7f119c5f3e74 (unknown)
@ 0x7f119c61819d (unknown)
@ 0x7f119c5f50a9 (unknown)
@ 0x7f119c605d0d (unknown)
@ 0x7f119c5e8472 (unknown)
@ 0x7f119c5639f5 (unknown)
@ 0x7f119c563a86 (unknown)
@ 0x7f119c53056a (unknown)
@ 0x7f11b324b9d4 (unknown)
@ 0x7f11b32306af (unknown)
@ 0x7f11b3256a75 (unknown)
@ 0x51aa69 caffe::caffe_gpu_set<>()
@ 0x53d71c caffe::ConvolutionLayer<>::Backward_gpu()
@ 0x4797ac caffe::Net<>::BackwardFromTo()
@ 0x4a72d7 caffe::Solver<>::Solve()
@ 0x4164b2 train()
@ 0x4104c1 main
@ 0x7f11ab428ec5 (unknown)
@ 0x414ee7 (unknown)
segment error.

To overcome the following error
F1219 15:59:41.175240 36602 common.cpp:137] Check failed: error == cudaSuccess (10 vs. 0) invalid device ordinal
please set the following parameter in the python code.
caffe.set_device(0)

I have the proble when i run :python examples/ssd/ssd_pascal.py
I solve the problem by vim examples/ssd/ssd_pascal.py modify

332 gpus = "0"

Check the file you are executing. There might be a value 'gpu = 0,1,2,3,4'. Change that to 'gpu = 0'.

This worked for me.

That solves the problem to me too

vim examples/ssd/ssd_pascal.py modify is really working for me

If you are running make runtest, and encountered this problem,
you can change the GPU id in Makefile.config.
Or you can try to run export CUDA_VISIBLE_DEVICES=0 before you run the make runtest.

Was this page helpful?
0 / 5 - 0 ratings