7

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!

talonmies
  • 70,661
  • 34
  • 192
  • 269
asPlankBridge
  • 1,032
  • 1
  • 17
  • 30
  • I think this is due to the structure that a ipython notebook is actually several components: server and kernels (ipcontroler & ipengine(s)). For optimus support in the engine you might therefore just create a "profile", then update the engine startup command to use optirun: https://ipython.org/ipython-doc/3/parallel/parallel_process.html – Ax3l Feb 20 '16 at 14:13

1 Answers1

4

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 :-).

roachsinai
  • 527
  • 5
  • 14