yosinski / deep-visualization-toolbox

DeepVis Toolbox
http://yosinski.com/deepvis
MIT License
4.01k stars 927 forks source link

Is there a way to set the GPU ID for multi-GPU systems? #112

Closed matthewgiarra closed 7 years ago

matthewgiarra commented 7 years ago

In app.py, after Caffe is imported on line 41, we have:

import caffe
  if settings.caffevis_mode_gpu:
            caffe.set_mode_gpu()
            print 'CaffeVisApp mode (in main thread):     GPU'
        else:
            caffe.set_mode_cpu() 

I would propose modifying this to something like:

import caffe
gpu_id = settings.gpu_id
  if settings.caffevis_mode_gpu:
            caffe.set_mode_gpu()
            if gpu_id is not None:
                       caffe.set_device(gpu_id)
            print 'CaffeVisApp mode (in main thread):     GPU'
        else:
            caffe.set_mode_cpu() 

I can make and submit this change if you're open to it.

yosinski commented 7 years ago

Setting the CUDA_VISIBLE_DEVICES environment variable is a more standard way, e.g.:

CUDA_VISIBLE_DEVICES=0 ./run_toolbox.py