Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IPython notebook with optirun

I want to run pycuda from an IPython notebook on a Linux laptop with NVIDIA Optimus (bumblebee). Usually, I can get a python script running by typing optirun python my_pycuda_script.py

But if I start optirun ipython notebook and then open a notebook, a new Kernel starts and I cannot run pycuda anymore. I found that if I replace my python executable by a shell script that calls optirun new_location_of_python it is working - but this is a pretty ugly hack. Is there a better way to do this? Maybe with a magic function, so that only the relevant notebooks are started with optirun?

Thanks for any help!

like image 670
asPlankBridge Avatar asked Jun 17 '14 15:06

asPlankBridge


1 Answers

I just found a solution from github:data_science_workspace.

GPU support for Jupyter:

For computers on linux with optimus, you have to make a kernel that will be called with "optirun" to be able to use GPU acceleration. For this go to the following folder:

cd ~/.local/share/jupyter/kernels/

then edit the file python3/kernel.json in order to add "optirun" as first entry into the argv array:

{
"language": "python",
"display_name": "Python 3",
"argv": [
    "optirun",
    "/home/fabien/.conda/envs/data_science/bin/python",
    "-m",
    "ipykernel",
    "-f",
    "{connection_file}"
    ]
}

But in my computer, the kernel.json is under: ~/miniconda3/envs/nn/share/jupyter/kernels/python3.

My conda info:

$ conda info
user-agent : conda/4.3.30 requests/2.14.2 CPython/3.6.1 Linux/4.9.79-1-MANJARO arch/Manjaro glibc/2.26

Hope this is what you need :-).

like image 108
roachsinai Avatar answered Oct 23 '22 21:10

roachsinai