1

I have 2 versions of tensorflow, cpu and gpu. And I am using conda to manage my environment. When I activate the cpu's one, dlib can run on GPU very well. But When I use the gpu's one, it just run on the cpu. I don't why, please help me.

There are some of my system information, I don't know it can give some information.

  • Ubuntu 18.04LTS
  • python 3.6
  • CUDA 10.1
  • tensorflow-gpu 1.9.0
  • tensorflow 1.12.0

Test code

conda activate ML

ipython

>>> import dlib

>>> dlib.DLIB_USE_CUDA

True

The code above output True but the code below output False.

conda activate ML_GPU

ipython

>>> import dlib

>>> dlib.DLIB_USE_CUDA

False

I hope when I using GPU version tensorflow dlib can using my GPU just like the CPU's one. Is anyone can help?

giser_yugang
  • 6,058
  • 4
  • 21
  • 44
Gingkens
  • 31
  • 6

1 Answers1

2

I had fixed this problem via install dlib manually. There are steps to do that.

Notice: You should do these steps on you virtual envs.

conda activate ML_GPU

pip uninstall dlib

git clone https://github.com/davisking/dlib.git

cd dlib

mkdir build

cd build

cmake .. -DDLIB_USE_CUDA=1 -DUSE_AVX_INSTRUCTIONS=1

cmake --build .

cd ..

python setup.py install

There still have a problem When you do the last step. You should notice if you see information like this one——CUDA was found but your compiler failed to compile a simple CUDA program so dlib isn't going to use CUDA.

Then you should change your g++ compiler version. You also can seek some info from
Install dlib with cuda support ubuntu 18.04 .

My g++ version is :(Ubuntu 6.5.0-2ubuntu1~18.04) 6.5.0 20181026. It looks like the newest version is not compatible with CUDA.

If everything is OK, You will see

>>> dlib.DLIB_USE_CUDA
True
Gingkens
  • 31
  • 6